Java Code Examples for org.apache.kylin.common.util.JsonUtil#writeValueAsIndentString()
The following examples show how to use
org.apache.kylin.common.util.JsonUtil#writeValueAsIndentString() .
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: HttpCoordinatorClient.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public void segmentRemoteStoreComplete(Node receiverNode, String cubeName, Pair<Long, Long> segmentRange) { logger.info("send receiver remote store complete message to coordinator"); try { RemoteStoreCompleteRequest completeRequest = new RemoteStoreCompleteRequest(); completeRequest.setCubeName(cubeName); completeRequest.setReceiverNode(receiverNode); completeRequest.setSegmentStart(segmentRange.getFirst()); completeRequest.setSegmentEnd(segmentRange.getSecond()); String content = JsonUtil.writeValueAsIndentString(completeRequest); postRequest("/remoteStoreComplete", content); } catch (IOException e) { throw new StreamingException(e); } }
Example 2
Source File: DstClusterUtil.java From kylin with Apache License 2.0 | 6 votes |
public void checkCompatibility(String projectName, Set<TableDesc> tableSet, DataModelDesc modelDesc, boolean ifHiveCheck) throws IOException { List<String> tableDataList = Lists.newArrayList(); for (TableDesc table : tableSet) { tableDataList.add(JsonUtil.writeValueAsIndentString(table)); } String modelDescData = JsonUtil.writeValueAsIndentString(modelDesc); CompatibilityCheckRequest request = new CompatibilityCheckRequest(); request.setProjectName(projectName); request.setTableDescDataList(tableDataList); request.setModelDescData(modelDescData); String jsonRequest = JsonUtil.writeValueAsIndentString(request); restClient.checkCompatibility(jsonRequest, ifHiveCheck); }
Example 3
Source File: ModelController.java From kylin with Apache License 2.0 | 6 votes |
@RequestMapping(value = "", method = { RequestMethod.PUT }, produces = { "application/json" }) @ResponseBody public ModelRequest updateModelDesc(@RequestBody ModelRequest modelRequest) throws JsonProcessingException { DataModelDesc modelDesc = deserializeDataModelDesc(modelRequest); if (modelDesc == null) { return modelRequest; } try { modelDesc = modelService.updateModelAndDesc(modelRequest.getProject(), modelDesc); } catch (AccessDeniedException accessDeniedException) { throw new ForbiddenException("You don't have right to update this model."); } catch (Exception e) { logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e); throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage(), e); } if (modelDesc.getError().isEmpty()) { modelRequest.setSuccessful(true); } else { logger.warn("Model " + modelDesc.getName() + " fail to update because " + modelDesc.getError()); updateRequest(modelRequest, false, omitMessage(modelDesc.getError())); } String descData = JsonUtil.writeValueAsIndentString(modelDesc); modelRequest.setModelDescData(descData); return modelRequest; }
Example 4
Source File: HttpCoordinatorClient.java From kylin with Apache License 2.0 | 6 votes |
@Override public void segmentRemoteStoreComplete(Node receiverNode, String cubeName, Pair<Long, Long> segmentRange) { logger.info("send receiver remote store complete message to coordinator"); try { RemoteStoreCompleteRequest completeRequest = new RemoteStoreCompleteRequest(); completeRequest.setCubeName(cubeName); completeRequest.setReceiverNode(receiverNode); completeRequest.setSegmentStart(segmentRange.getFirst()); completeRequest.setSegmentEnd(segmentRange.getSecond()); String content = JsonUtil.writeValueAsIndentString(completeRequest); postRequest("/remoteStoreComplete", content); } catch (IOException e) { throw new StreamingException(e); } }
Example 5
Source File: ModelController.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@RequestMapping(value = "", method = { RequestMethod.PUT }, produces = { "application/json" }) @ResponseBody public ModelRequest updateModelDesc(@RequestBody ModelRequest modelRequest) throws JsonProcessingException { DataModelDesc modelDesc = deserializeDataModelDesc(modelRequest); if (modelDesc == null) { return modelRequest; } try { modelDesc = modelService.updateModelAndDesc(modelRequest.getProject(), modelDesc); } catch (AccessDeniedException accessDeniedException) { throw new ForbiddenException("You don't have right to update this model."); } catch (Exception e) { logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e); throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage(), e); } if (modelDesc.getError().isEmpty()) { modelRequest.setSuccessful(true); } else { logger.warn("Model " + modelDesc.getName() + " fail to update because " + modelDesc.getError()); updateRequest(modelRequest, false, omitMessage(modelDesc.getError())); } String descData = JsonUtil.writeValueAsIndentString(modelDesc); modelRequest.setModelDescData(descData); return modelRequest; }
Example 6
Source File: MigrationRuleSet.java From kylin with Apache License 2.0 | 6 votes |
public void checkSchema(Context ctx) throws IOException { Set<TableDesc> tableSet = Sets.newHashSet(); for (TableRef tableRef : ctx.getCubeInstance().getModel().getAllTables()) { tableSet.add(tableRef.getTableDesc()); } List<String> tableDataList = Lists.newArrayList(); for (TableDesc table : tableSet) { tableDataList.add(JsonUtil.writeValueAsIndentString(table)); } DataModelDesc model = ctx.getCubeInstance().getModel(); String modelDescData = JsonUtil.writeValueAsIndentString(model); CompatibilityCheckRequest request = new CompatibilityCheckRequest(); request.setProjectName(ctx.getTgtProjectName()); request.setTableDescDataList(tableDataList); request.setModelDescData(modelDescData); String jsonRequest = JsonUtil.writeValueAsIndentString(request); RestClient client = new RestClient(ctx.getTargetAddress()); client.checkCompatibility(jsonRequest); }
Example 7
Source File: DataModelDescTest.java From kylin with Apache License 2.0 | 5 votes |
@Test public void testGetCopyOf() throws JsonProcessingException { DataModelDesc desc = DataModelManager.getInstance(getTestConfig()).getDataModelDesc("test_kylin_inner_join_model_desc"); DataModelDesc copyDesc = DataModelDesc.getCopyOf(desc); // uuid is different, set to equals for json comparison copyDesc.setUuid(desc.getUuid()); copyDesc.setLastModified(desc.getLastModified()); String descStr = JsonUtil.writeValueAsIndentString(desc); String copyStr = JsonUtil.writeValueAsIndentString(copyDesc); assertEquals(descStr, copyStr); }
Example 8
Source File: SnapshotTableSerializer.java From kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(SnapshotTable obj, DataOutputStream out) throws IOException { String json = JsonUtil.writeValueAsIndentString(obj); out.writeUTF(json); if (infoOnly == false) obj.writeData(out); }
Example 9
Source File: HttpCoordinatorClient.java From kylin with Apache License 2.0 | 5 votes |
@Override public void reAssignCube(String cubeName, CubeAssignment newAssignments) { logger.info("send reassign request to coordinator"); try { String path = CUBES + cubeName + "/reAssign"; String content = JsonUtil.writeValueAsIndentString(newAssignments); postRequest(path, content); } catch (IOException e) { throw new StreamingException(e); } }
Example 10
Source File: SnapshotTableSerializer.java From Kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(SnapshotTable obj, DataOutputStream out) throws IOException { String json = JsonUtil.writeValueAsIndentString(obj); out.writeUTF(json); if (infoOnly == false) obj.writeData(out); }
Example 11
Source File: HttpCoordinatorClient.java From kylin with Apache License 2.0 | 5 votes |
@Override public void replicaSetLeaderChange(int replicaSetId, Node newLeader) { logger.info("send replicaSet lead change notification to coordinator"); try { ReplicaSetLeaderChangeRequest changeRequest = new ReplicaSetLeaderChangeRequest(); changeRequest.setReplicaSetID(replicaSetId); changeRequest.setNewLeader(newLeader); String content = JsonUtil.writeValueAsIndentString(changeRequest); postRequest("/replicaSetLeaderChange", content); } catch (IOException e) { throw new StreamingException(e); } }
Example 12
Source File: CheckPointStore.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public void saveCheckPoint(CheckPoint cp) { try (FileOutputStream outputStream = FileUtils.openOutputStream(getCheckPointFile(cp), true)) { String jsonCP = JsonUtil.writeValueAsIndentString(cp); outputStream.write(Bytes.toBytes(wrapCheckPointString(jsonCP))); outputStream.flush(); } catch (Exception e) { logger.error("CheckPoint error for cube " + cubeName, e); } }
Example 13
Source File: CubeDescTest.java From kylin with Apache License 2.0 | 5 votes |
@Test public void testSerialize() throws Exception { CubeDesc desc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); String str = JsonUtil.writeValueAsIndentString(desc); //System.out.println(str); @SuppressWarnings("unused") CubeDesc desc2 = JsonUtil.readValue(str, CubeDesc.class); }
Example 14
Source File: SnapshotTableSerializer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public void serialize(SnapshotTable obj, DataOutputStream out) throws IOException { String json = JsonUtil.writeValueAsIndentString(obj); out.writeUTF(json); if (infoOnly == false) obj.writeData(out); }
Example 15
Source File: DictionaryInfoSerializer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public void serialize(DictionaryInfo obj, DataOutputStream out) throws IOException { String json = JsonUtil.writeValueAsIndentString(obj); out.writeUTF(json); if (infoOnly == false) obj.getDictionaryObject().write(out); }
Example 16
Source File: DataModelDescTest.java From kylin with Apache License 2.0 | 5 votes |
@Test public void testPartitionDescCopyOf() throws JsonProcessingException { PartitionDesc desc = DataModelManager.getInstance(getTestConfig()).getDataModelDesc("test_kylin_inner_join_model_desc").partitionDesc; PartitionDesc copyDesc = PartitionDesc.getCopyOf(desc); String descStr = JsonUtil.writeValueAsIndentString(desc); String copyStr = JsonUtil.writeValueAsIndentString(copyDesc); assertEquals(descStr, copyStr); }
Example 17
Source File: HttpCoordinatorClient.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public void createReplicaSet(ReplicaSet rs) { logger.info("send create replicaSet request to coordinator"); try { String path = "/replicaSet"; String content = JsonUtil.writeValueAsIndentString(rs); postRequest(path, content); } catch (IOException e) { throw new StreamingException(e); } }
Example 18
Source File: DictionaryInfoSerializer.java From kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(DictionaryInfo obj, DataOutputStream out) throws IOException { String json = JsonUtil.writeValueAsIndentString(obj); out.writeUTF(json); if (infoOnly == false) obj.getDictionaryObject().write(out); }
Example 19
Source File: CubeDescTest.java From kylin with Apache License 2.0 | 5 votes |
@Test public void testGetCopyOf() throws Exception { CubeDesc desc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc(CUBE_WITH_SLR_DESC); CubeDesc copyDesc = CubeDesc.getCopyOf(desc); // uuid is different, set to equals for json comparison copyDesc.setUuid(desc.getUuid()); copyDesc.setLastModified(desc.getLastModified()); String descStr = JsonUtil.writeValueAsIndentString(desc); String copyStr = JsonUtil.writeValueAsIndentString(copyDesc); assertEquals(descStr, copyStr); }
Example 20
Source File: DictionaryInfoSerializer.java From Kylin with Apache License 2.0 | 5 votes |
@Override public void serialize(DictionaryInfo obj, DataOutputStream out) throws IOException { String json = JsonUtil.writeValueAsIndentString(obj); out.writeUTF(json); if (infoOnly == false) obj.getDictionaryObject().write(out); }