Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.zeppelin.interpreter.InterpreterSetting;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcessListener;
import org.apache.zeppelin.notebook.*;
import org.apache.zeppelin.notebook.repo.NotebookRepo.Revision;
import org.apache.zeppelin.notebook.socket.Message;
import org.apache.zeppelin.notebook.socket.Message.OP;
import org.apache.zeppelin.scheduler.Job;
Expand Down Expand Up @@ -220,6 +221,9 @@ public void onMessage(NotebookSocket conn, String msg) {
case CHECKPOINT_NOTEBOOK:
checkpointNotebook(conn, notebook, messagereceived);
break;
case NOTE_REVISION:
getNoteRevision(conn, notebook, messagereceived);
break;
case LIST_NOTEBOOK_JOBS:
unicastNotebookJobInfo(conn, messagereceived);
break;
Expand Down Expand Up @@ -1129,6 +1133,18 @@ private void checkpointNotebook(NotebookSocket conn, Notebook notebook,
notebook.checkpointNote(noteId, commitMessage, subject);
}

private void getNoteRevision(NotebookSocket conn, Notebook notebook, Message fromMessage)
throws IOException {
String noteId = (String) fromMessage.get("noteId");
Revision revision = (Revision) fromMessage.get("revision");
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
Note revisionNote = notebook.getNoteRevision(noteId, revision, subject);
conn.send(serializeMessage(new Message(OP.NOTE_REVISION)
.put("noteId", noteId)
.put("revisionId", revision)
.put("data", revisionNote)));
}

/**
* This callback is for the paragraph that runs on ZeppelinServer
* @param noteId
Expand Down
6 changes: 6 additions & 0 deletions zeppelin-web/src/app/notebook/notebook.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
document.getElementById('note.checkpoint.message').value = '';
};

// receive certain revision of note
$scope.$on('noteRevision', function(event, data) {
console.log('received note revision %o', data);
//TODO(xxx): render it
});

$scope.runNote = function() {
BootstrapDialog.confirm({
closable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ angular.module('zeppelinWebApp').factory('websocketEvents',
$rootScope.$broadcast('appLoad', data);
} else if (op === 'APP_STATUS_CHANGE') {
$rootScope.$broadcast('appStatusChange', data);
} else if (op === 'NOTE_REVISION') {
$rootScope.$broadcast('noteRevision', data);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope,
});
},

getNoteRevision: function(noteId, revisionId) {
websocketEvents.sendNewEvent({
op: 'NOTE_REVISION',
data: {
noteId: noteId,
revisionId: revisionId
}
});
},

isConnected: function() {
return websocketEvents.isConnected();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.zeppelin.interpreter.InterpreterSetting;
import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry;
import org.apache.zeppelin.notebook.repo.NotebookRepo;
import org.apache.zeppelin.notebook.repo.NotebookRepo.Revision;
import org.apache.zeppelin.notebook.repo.NotebookRepoSync;
import org.apache.zeppelin.resource.ResourcePoolUtils;
import org.apache.zeppelin.scheduler.Job;
Expand Down Expand Up @@ -357,6 +358,11 @@ public void checkpointNote(String noteId, String checkpointMessage, Authenticati
notebookRepo.checkpoint(noteId, checkpointMessage, subject);
}

public Note getNoteRevision(String noteId, Revision revision, AuthenticationInfo subject)
throws IOException {
return notebookRepo.get(noteId, revision, subject);
}

@SuppressWarnings("rawtypes")
private Note loadNoteFromRepo(String id, AuthenticationInfo subject) {
Note note = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,14 @@ public Revision checkpoint(String noteId, String checkpointMsg, AuthenticationIn
}

@Override
public Note get(String noteId, Revision rev, AuthenticationInfo subject) throws IOException {
// Auto-generated method stub
return null;
public Note get(String noteId, Revision rev, AuthenticationInfo subject) {
Note revisionNote = null;
try {
revisionNote = getRepo(0).get(noteId, rev, subject);
} catch (IOException e) {
LOG.error("Failed to get revision {} of note {}", rev.id, noteId, e);
}
return revisionNote;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public static enum OP {
CHECKPOINT_NOTEBOOK, // [c-s] checkpoint notebook to storage repository
// @param noteId
// @param checkpointName
NOTE_REVISION, // [c-s] get certain revision of note
// @param noteId
// @param revisionId

APP_APPEND_OUTPUT, // [s-c] append output
APP_UPDATE_OUTPUT, // [s-c] update (replace) output
Expand Down