Skip to content

Commit

Permalink
Desactivate ws :: we will need to refactor this part
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycorbacho committed Nov 21, 2016
1 parent e884203 commit edb9e8c
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.zeppelin.notebook.repo.zeppelinhub.model.Instance;
import org.apache.zeppelin.notebook.repo.zeppelinhub.model.UserSessionContainer;
import org.apache.zeppelin.notebook.repo.zeppelinhub.rest.ZeppelinhubRestApiHandler;
import org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.Client;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -55,7 +54,7 @@ public class ZeppelinHubRepo implements NotebookRepo {
public static final String TOKEN_HEADER = "X-Zeppelin-Token";
private static final Gson GSON = new Gson();
private static final Note EMPTY_NOTE = new Note();
private final Client websocketClient;
//private final Client websocketClient;

private String token;
private ZeppelinhubRestApiHandler restApiClient;
Expand All @@ -69,9 +68,10 @@ public ZeppelinHubRepo(ZeppelinConfiguration conf) {
token = conf.getString("ZEPPELINHUB_API_TOKEN", ZEPPELIN_CONF_PROP_NAME_TOKEN, "");
restApiClient = ZeppelinhubRestApiHandler.newInstance(zeppelinHubUrl, token);

websocketClient = Client.initialize(getZeppelinWebsocketUri(conf),
getZeppelinhubWebsocketUri(conf), token, conf);
websocketClient.start();
// TODO(xxx): refactor this in the next itaration
//websocketClient = Client.initialize(getZeppelinWebsocketUri(conf),
// getZeppelinhubWebsocketUri(conf), token, conf);
//websocketClient.start();
}

private String getZeppelinHubWsUri(URI api) throws URISyntaxException {
Expand Down Expand Up @@ -160,9 +160,11 @@ private String getUserZeppelinInstanceToken(String ticket) throws IOException {
if (StringUtils.isBlank(ticket)) {
return "";
}

List<Instance> instances = restApiClient.getInstances(ticket);
// TODO(anthony): Implement NotebookRepo Setting to let user switch token at runtime.
token = instances.get(0).token;

token = instances.isEmpty() ? StringUtils.EMPTY : instances.get(0).token;
return token;
}

Expand Down Expand Up @@ -202,7 +204,7 @@ public List<NoteInfo> list(AuthenticationInfo subject) throws IOException {

@Override
public Note get(String noteId, AuthenticationInfo subject) throws IOException {
if (StringUtils.isBlank(noteId)) {
if (StringUtils.isBlank(noteId) || subject == null) {
return EMPTY_NOTE;
}
String token = getUserToken(subject.getUser());
Expand Down Expand Up @@ -235,7 +237,7 @@ public void remove(String noteId, AuthenticationInfo subject) throws IOException

@Override
public void close() {
websocketClient.stop();
//websocketClient.stop();
}

@Override
Expand Down

0 comments on commit edb9e8c

Please sign in to comment.