mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-2714] Improvements to change request
This commit is contained in:
parent
a85864c016
commit
294dea8fbc
5 changed files with 38 additions and 23 deletions
|
|
@ -615,7 +615,7 @@ The role of registered interpreters, settings and interpreters group are describ
|
|||
</tr>
|
||||
<tr>
|
||||
<td>URL</td>
|
||||
<td>```http://[zeppelin-server]:[zeppelin-port]/api/interpreter/getmetainfos/[setting ID]```</td>
|
||||
<td>```http://[zeppelin-server]:[zeppelin-port]/api/interpreter/metadata/[setting ID]```</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Success code</td>
|
||||
|
|
|
|||
|
|
@ -188,8 +188,10 @@ public class SparkInterpreter extends Interpreter {
|
|||
String jobUrl = getJobUrl(jobId);
|
||||
String noteId = Utils.getNoteId(jobGroupId);
|
||||
String paragraphId = Utils.getParagraphId(jobGroupId);
|
||||
|
||||
if (uiEnabled != "false" && jobUrl != null) {
|
||||
// Button visible if Spark UI property not set, set as invalid boolean or true
|
||||
java.lang.Boolean showSparkUI =
|
||||
uiEnabled == null || !uiEnabled.trim().toLowerCase().equals("false");
|
||||
if (showSparkUI && jobUrl != null) {
|
||||
RemoteEventClientWrapper eventClient = BaseZeppelinContext.getEventClient();
|
||||
Map<String, String> infos = new java.util.HashMap<>();
|
||||
infos.put("jobUrl", jobUrl);
|
||||
|
|
@ -1046,9 +1048,17 @@ public class SparkInterpreter extends Interpreter {
|
|||
infos.put("url", sparkUrl);
|
||||
java.lang.Boolean uiEnabled = java.lang.Boolean.parseBoolean(
|
||||
property.getProperty("spark.ui.enabled", "true"));
|
||||
infos.put("sparkUiEnabled", uiEnabled.toString());
|
||||
if (!uiEnabled) {
|
||||
infos.put("message", "Spark UI disabled");
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(sparkUrl)) {
|
||||
infos.put("message", "Spark UI enabled");
|
||||
} else {
|
||||
infos.put("message", "No spark url defined");
|
||||
}
|
||||
}
|
||||
if (ctx != null && ctx.getClient() != null) {
|
||||
logger.info("Sending metainfos to Zeppelin server: {}", infos.toString());
|
||||
logger.info("Sending metadata to Zeppelin server: {}", infos.toString());
|
||||
getZeppelinContext().setEventClient(ctx.getClient());
|
||||
ctx.getClient().onMetaInfosReceived(infos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,10 +246,10 @@ public class InterpreterRestApi {
|
|||
}
|
||||
|
||||
/**
|
||||
* get the metainfo property value
|
||||
* get metadata values
|
||||
*/
|
||||
@GET
|
||||
@Path("getmetainfos/{settingId}")
|
||||
@Path("metadata/{settingId}")
|
||||
@ZeppelinApi
|
||||
public Response getMetaInfo(@Context HttpServletRequest req,
|
||||
@PathParam("settingId") String settingId) {
|
||||
|
|
@ -258,7 +258,7 @@ public class InterpreterRestApi {
|
|||
return new JsonResponse<>(Status.NOT_FOUND).build();
|
||||
}
|
||||
Map<String, String> infos = interpreterSetting.getInfos();
|
||||
return new JsonResponse<>(Status.OK, "metainfo", infos).build();
|
||||
return new JsonResponse<>(Status.OK, "metadata", infos).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import com.google.gson.JsonArray;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.apache.commons.collections.map.HashedMap;
|
||||
import org.apache.commons.httpclient.methods.DeleteMethod;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
|
|
@ -367,7 +366,7 @@ public class InterpreterRestApiTest extends AbstractTestRestApi {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetMetaInfo() throws IOException {
|
||||
public void testGetMetadataInfo() throws IOException {
|
||||
String rawRequest = "{\"name\":\"spark\",\"group\":\"spark\"," +
|
||||
"\"properties\":{\"propname\":\"propvalue\"}," +
|
||||
"\"interpreterGroup\":[{\"class\":\"org.apache.zeppelin.markdown.Markdown\",\"name\":\"md\"}]," +
|
||||
|
|
@ -381,10 +380,16 @@ public class InterpreterRestApiTest extends AbstractTestRestApi {
|
|||
infos.put("key1", "value1");
|
||||
infos.put("key2", "value2");
|
||||
ZeppelinServer.notebook.getInterpreterSettingManager().get(settingId).setInfos(infos);
|
||||
GetMethod get = httpGet("/interpreter/getmetainfos/" + settingId);
|
||||
GetMethod get = httpGet("/interpreter/metadata/" + settingId);
|
||||
assertThat(get, isAllowed());
|
||||
JsonObject body = getBodyFieldFromResponse(get.getResponseBodyAsString());
|
||||
assertEquals(body.entrySet().size(), infos.size());
|
||||
java.util.Map.Entry<String, JsonElement> item = body.entrySet().iterator().next();
|
||||
if (item.getKey().equals("key1")) {
|
||||
assertEquals(item.getValue().getAsString(), "value1");
|
||||
} else {
|
||||
assertEquals(item.getValue().getAsString(), "value2");
|
||||
}
|
||||
get.releaseConnection();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -754,21 +754,21 @@ function InterpreterCtrl($rootScope, $scope, $http, baseUrlSrv, ngToast, $timeou
|
|||
}
|
||||
|
||||
$scope.showSparkUI = function (settingId) {
|
||||
$http.get(baseUrlSrv.getRestApiBase() + '/interpreter/getmetainfos/' + settingId)
|
||||
$http.get(baseUrlSrv.getRestApiBase() + '/interpreter/metadata/' + settingId)
|
||||
.success(function (data, status, headers, config) {
|
||||
if (data.body === undefined || !data.body.url) {
|
||||
if (data.body !== undefined && data.body.sparkUiEnabled === 'false') {
|
||||
BootstrapDialog.alert({
|
||||
message: 'Spark Web UI disabled. Set spark.ui.enabled property'
|
||||
})
|
||||
} else {
|
||||
BootstrapDialog.alert({
|
||||
message: 'No spark application running'
|
||||
})
|
||||
}
|
||||
if (data.body === undefined) {
|
||||
BootstrapDialog.alert({
|
||||
message: 'No spark application running'
|
||||
})
|
||||
return
|
||||
}
|
||||
window.open(data.body.url, '_blank')
|
||||
if (data.body.url) {
|
||||
window.open(data.body.url, '_blank')
|
||||
} else {
|
||||
BootstrapDialog.alert({
|
||||
message: data.body.message
|
||||
})
|
||||
}
|
||||
}).error(function (data, status, headers, config) {
|
||||
console.log('Error %o %o', status, data.message)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue