use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InlongGroupImpl method initOnUpdate.
@Override
public InlongGroupContext initOnUpdate(InlongGroupConf conf) throws Exception {
update(conf);
InlongGroupInfo groupInfo = InlongGroupTransfer.createGroupInfo(conf);
InlongGroupRequest groupRequest = groupInfo.genRequest();
Pair<Boolean, InlongGroupResponse> existMsg = managerClient.isGroupExists(groupRequest);
if (existMsg.getKey()) {
groupInfo = CommonBeanUtils.copyProperties(existMsg.getValue(), InlongGroupInfo::new);
this.groupContext.setGroupInfo(groupInfo);
return init();
} else {
throw new RuntimeException(String.format("Group is not found by groupName=%s", groupInfo.getName()));
}
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InnerInlongManagerClient method getGroupInfo.
public InlongGroupResponse getGroupInfo(String inlongGroupId) {
if (StringUtils.isEmpty(inlongGroupId)) {
throw new IllegalArgumentException("InlongGroupId should not be empty");
}
String path = HTTP_PATH + "/group/get/" + inlongGroupId;
final String url = formatUrl(path);
Request request = new Request.Builder().get().url(url).build();
Call call = httpClient.newCall(request);
try {
Response response = call.execute();
assert response.body() != null;
String body = response.body().string();
AssertUtil.isTrue(response.isSuccessful(), String.format("Inlong request failed: %s", body));
org.apache.inlong.manager.common.beans.Response responseBody = InlongParser.parseResponse(body);
if (responseBody.getErrMsg() != null) {
if (responseBody.getErrMsg().contains("Inlong group does not exist")) {
return null;
} else {
throw new RuntimeException(responseBody.getErrMsg());
}
} else {
return InlongParser.parseGroupInfo(responseBody);
}
} catch (Exception e) {
throw new RuntimeException(String.format("Inlong group get failed: %s", e.getMessage()), e);
}
}
use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse in project incubator-inlong by apache.
the class InnerInlongManagerClient method isGroupExists.
public Pair<Boolean, InlongGroupResponse> isGroupExists(InlongGroupRequest groupInfo) {
String inlongGroupId = groupInfo.getInlongGroupId();
if (StringUtils.isEmpty(inlongGroupId)) {
inlongGroupId = "b_" + groupInfo.getName();
}
InlongGroupResponse currentBizInfo = getGroupInfo(inlongGroupId);
if (currentBizInfo != null) {
return Pair.of(true, currentBizInfo);
} else {
return Pair.of(false, null);
}
}
Aggregations