Address review comments

Signed-off-by: Karup <karuppayya@outlook.com>
This commit is contained in:
Karup 2016-12-18 09:30:37 +05:30
parent b837c6cb0b
commit fc44d9b479
9 changed files with 51 additions and 59 deletions

View file

@ -173,6 +173,7 @@ public class SparkInterpreter extends Interpreter {
Map<String, String> infos = new java.util.HashMap<>();
infos.put("jobUrl", jobUrl);
infos.put("label", "SPARK JOB");
infos.put("tooltip", "View in Spark web UI");
if (eventClient != null) {
eventClient.onParaInfosReceived(noteId, paragraphId, infos);
}

View file

@ -20,6 +20,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@ -2325,12 +2326,18 @@ public class NotebookServer extends WebSocketServlet
InterpreterSetting setting = notebook().getInterpreterFactory()
.get(interpreterSettingId);
setting.addNoteToPara(noteId, paragraphId);
metaInfos.remove("noteId");
metaInfos.remove("paraId");
String label = metaInfos.get("label");
metaInfos.remove("label");
paragraph.updateRuntimeInfos(label, metaInfos, setting.getGroup(), setting.getId());
broadcast(note.getId(), new Message(OP.PARAGRAPH).put("paragraph", paragraph));
String tooltip = metaInfos.get("tooltip");
List<String> keysToRemove = Arrays.asList("noteId", "paraId", "label", "tooltip");
for (String removeKey : keysToRemove) {
metaInfos.remove(removeKey);
}
paragraph
.updateRuntimeInfos(label, tooltip, metaInfos, setting.getGroup(), setting.getId());
broadcast(
note.getId(),
new Message(OP.PARAS_INFO).put("id", paragraphId).put("infos",
paragraph.getRuntimeInfos()));
}
}
}

View file

@ -13,14 +13,14 @@ limitations under the License.
-->
<div id="{{paragraph.id}}_control" class="control" ng-show="!asIframe">
<span ng-show="paragraph.runtimeInfos.jobUrl.values.length == 1 && paragraph.runtimeInfos.jobUrl.group == 'spark'">
<span ng-show="paragraph.runtimeInfos.jobUrl.values.length == 1">
<a href="{{paragraph.runtimeInfos.jobUrl.values[0]}}" target="_blank" style="text-decoration: none;">
<span class="fa fa-tasks"></span>
{{paragraph.runtimeInfos.jobUrl.label}}
</a>
</span>
<span class="dropdown" ng-show="paragraph.runtimeInfos.jobUrl.values.length > 1 && paragraph.runtimeInfos.jobUrl.group == 'spark'">
<span style="cursor:pointer;color:#3071A9" tooltip-placement="top" tooltip="View in Spark web UI"
<span class="dropdown" ng-show="paragraph.runtimeInfos.jobUrl.values.length > 1">
<span style="cursor:pointer;color:#3071A9" tooltip-placement="top" tooltip="{{paragraph.runtimeInfos.jobUrl.tooltip}}"
data-toggle="dropdown" type="button">
<span class="fa fa-tasks"></span>
{{paragraph.runtimeInfos.jobUrl.label}}S

View file

@ -1036,6 +1036,12 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
}
});
$scope.$on('updateParaInfos', function(event, data) {
if (data.id === $scope.paragraph.id) {
$scope.paragraph.runtimeInfos = data.infos;
}
});
$scope.$on('angularObjectRemove', function(event, data) {
var noteId = $route.current.pathParams.noteId;
if (!data.noteId || data.noteId === noteId) {
@ -1084,7 +1090,7 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
newPara.errorMessage !== oldPara.errorMessage ||
!angular.equals(newPara.settings, oldPara.settings) ||
!angular.equals(newPara.config, oldPara.config) ||
!angular.equals(newPara.runtimeInfos, oldPara.runtimeInfos)))
!angular.equals(newPara.runtimeInfos, oldPara.runtimeInfos)))
}
$scope.updateAllScopeTexts = function(oldPara, newPara) {
@ -1132,39 +1138,6 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
$scope.editor.setReadOnly($scope.isRunning(newPara));
}
if (!$scope.asIframe) {
$scope.paragraph.config = newPara.config;
initializeDefault(newPara.config);
} else {
newPara.config.editorHide = true;
newPara.config.tableHide = false;
$scope.paragraph.config = newPara.config;
}
};
$scope.updateParagraph = function(oldPara, newPara, updateCallback) {
// 1. get status, refreshed
const statusChanged = (newPara.status !== oldPara.status);
const resultRefreshed = (newPara.dateFinished !== oldPara.dateFinished) ||
isEmpty(newPara.results) !== isEmpty(oldPara.results) ||
newPara.status === 'ERROR' || (newPara.status === 'FINISHED' && statusChanged);
// 2. update texts managed by $scope
$scope.updateAllScopeTexts(oldPara, newPara);
// 3. execute callback to update result
updateCallback();
// 4. update remaining paragraph objects
$scope.updateParagraphObjectWhenUpdated(newPara);
// 5. handle scroll down by key properly if new paragraph is added
if (statusChanged || resultRefreshed) {
// when last paragraph runs, zeppelin automatically appends new paragraph.
// this broadcast will focus to the newly inserted paragraph
const paragraphs = angular.element('div[id$="_paragraphColumn_main"]');
if (paragraphs.length >= 2 && paragraphs[paragraphs.length - 2].id.indexOf($scope.paragraph.id) === 0) {
// rendering output can took some time. So delay scrolling event firing for sometime.
setTimeout(() => { $rootScope.$broadcast('scrollToCursor'); }, 500);
}
}
};

View file

@ -164,6 +164,8 @@ function websocketEvents($rootScope, $websocket, $location, baseUrlSrv) {
$rootScope.$broadcast('updateNote', data.name, data.config, data.info);
} else if (op === 'SET_NOTE_REVISION') {
$rootScope.$broadcast('setNoteRevisionResult', data);
} else if (op === 'PARAS_INFO') {
$rootScope.$broadcast('updateParaInfos', data);
}
});

View file

@ -48,7 +48,10 @@ public class InterpreterSetting {
// always be null in case of InterpreterSettingRef
private String group;
private transient Map<String, String> infos;
private transient Map<String, Set<String>> noteIdToParaIdsetMap;
// Map of the note and paragraphs which has runtime infos generated by this interpreter setting.
// This map is used to clear the infos in paragraph when the interpretersetting is restarted
private transient Map<String, Set<String>> runtimeInfosToBeCleared;
/**
* properties can be either Properties or Map<String, InterpreterProperty>
@ -396,32 +399,31 @@ public class InterpreterSetting {
return infos;
}
<<<<<<< b1e06919fada4240f5440430f2c27c02e4e5626a
public InterpreterRunner getInterpreterRunner() {
return interpreterRunner;
}
public void setInterpreterRunner(InterpreterRunner interpreterRunner) {
this.interpreterRunner = interpreterRunner;
=======
}
public void addNoteToPara(String noteId, String paraId) {
if (noteIdToParaIdsetMap == null) {
noteIdToParaIdsetMap = new HashMap<>();
if (runtimeInfosToBeCleared == null) {
runtimeInfosToBeCleared = new HashMap<>();
}
Set<String> paraIdSet = noteIdToParaIdsetMap.get(noteId);
Set<String> paraIdSet = runtimeInfosToBeCleared.get(noteId);
if (paraIdSet == null) {
paraIdSet = new HashSet<>();
noteIdToParaIdsetMap.put(noteId, paraIdSet);
runtimeInfosToBeCleared.put(noteId, paraIdSet);
}
paraIdSet.add(paraId);
}
public Map<String, Set<String>> getNoteIdAndParaMap() {
return noteIdToParaIdsetMap;
>>>>>>> Ability to view spark job urls in each paragraph
}
public void clearNoteIdAndParaMap() {
noteIdToParaIdsetMap = null;
runtimeInfosToBeCleared = null;
}
}

View file

@ -679,8 +679,8 @@ public class Paragraph extends Job implements Serializable, Cloneable {
}
}
public void updateRuntimeInfos(String label, Map<String, String> infos, String group,
String intpSettingId) {
public void updateRuntimeInfos(String label, String tooltip, Map<String, String> infos,
String group, String intpSettingId) {
if (this.runtimeInfos == null) {
this.runtimeInfos = new HashMap<String, ParagraphRuntimeInfo>();
}
@ -689,7 +689,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
for (String key : infos.keySet()) {
ParagraphRuntimeInfo info = this.runtimeInfos.get(key);
if (info == null) {
info = new ParagraphRuntimeInfo(key, label, group, intpSettingId);
info = new ParagraphRuntimeInfo(key, label, tooltip, group, intpSettingId);
this.runtimeInfos.put(key, info);
}
info.addValue(infos.get(key));
@ -722,4 +722,8 @@ public class Paragraph extends Job implements Serializable, Cloneable {
this.runtimeInfos = null;
}
}
public Map<String, ParagraphRuntimeInfo> getRuntimeInfos() {
return runtimeInfos;
}
}

View file

@ -9,19 +9,21 @@ import java.util.List;
*/
public class ParagraphRuntimeInfo {
private String propertyName; //Name of the property
private String label; //Label to be used in UI
private String group; //The interpretergroup from which the info was derived
private String propertyName; // Name of the property
private String label; // Label to be used in UI
private String tooltip; // Tooltip text toshow in UI
private String group; // The interpretergroup from which the info was derived
private List<String> values; // values for the property
private String interpreterSettingId;
public ParagraphRuntimeInfo(String propertyName, String label,
String group, String intpSettingId) {
String tooltip, String group, String intpSettingId) {
if (intpSettingId == null) {
throw new IllegalArgumentException("Interpreter setting Id cannot be null");
}
this.propertyName = propertyName;
this.label = label;
this.tooltip = tooltip;
this.group = group;
this.interpreterSettingId = intpSettingId;
this.values = new ArrayList<>();

View file

@ -174,7 +174,8 @@ public class Message {
NOTE_UPDATED, // [s-c] paragraph updated(name, config)
RUN_ALL_PARAGRAPHS, // [c-s] run all paragraphs
PARAGRAPH_EXECUTED_BY_SPELL, // [c-s] paragraph was executed by spell
RUN_PARAGRAPH_USING_SPELL // [s-c] run paragraph using spell
RUN_PARAGRAPH_USING_SPELL, // [s-c] run paragraph using spell
PARAS_INFO // [s-c] paragraph runtime infos
}
public static final Message EMPTY = new Message(null);