ZEPPELIN-1707. Pass userName when creating interpreter through thrift

This commit is contained in:
Jeff Zhang 2016-11-25 09:58:15 +08:00
parent 9694a1a5bb
commit a247552be1
13 changed files with 593 additions and 366 deletions

View file

@ -142,6 +142,7 @@ public abstract class Interpreter {
private InterpreterGroup interpreterGroup;
private URL [] classloaderUrls;
protected Properties property;
private String userName;
@ZeppelinApi
public Interpreter(Properties property) {
@ -187,6 +188,14 @@ public abstract class Interpreter {
return this.getClass().getName();
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return this.userName;
}
public void setInterpreterGroup(InterpreterGroup interpreterGroup) {
this.interpreterGroup = interpreterGroup;
}

View file

@ -52,7 +52,8 @@ public class ZeppelinDevServer extends
"dev",
sessionKey,
DevInterpreter.class.getName(),
new HashMap<String, String>());
new HashMap<String, String>(),
"anonymous");
Interpreter intp = super.getInterpreter(sessionKey, className);
interpreter = (DevInterpreter) (

View file

@ -239,8 +239,7 @@ public class RemoteInterpreter extends Interpreter {
property.put("zeppelin.interpreter.localRepo", localRepoPath);
}
client.createInterpreter(groupId, sessionKey,
getClassName(), (Map) property);
getClassName(), (Map) property, userName);
// Push angular object loaded from JSON file to remote interpreter
if (!interpreterGroup.isAngularRegistryPushed()) {
pushAngularObjectRegistryToRemote(client);

View file

@ -147,10 +147,9 @@ public class RemoteInterpreterServer
System.exit(0);
}
@Override
public void createInterpreter(String interpreterGroupId, String sessionKey, String
className, Map<String, String> properties) throws TException {
className, Map<String, String> properties, String userName) throws TException {
if (interpreterGroup == null) {
interpreterGroup = new InterpreterGroup(interpreterGroupId);
angularObjectRegistry = new AngularObjectRegistry(interpreterGroup.getId(), this);
@ -189,6 +188,7 @@ public class RemoteInterpreterServer
logger.info("Instantiate interpreter {}", className);
repl.setInterpreterGroup(interpreterGroup);
repl.setUserName(userName);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException
| InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {

View file

@ -1,11 +1,29 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.zeppelin.interpreter.thrift;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
@ -29,12 +47,9 @@ import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-11-18")
public class InterpreterCompletion implements org.apache.thrift.TBase<InterpreterCompletion, InterpreterCompletion._Fields>, java.io.Serializable, Cloneable, Comparable<InterpreterCompletion> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("InterpreterCompletion");
@ -289,19 +304,19 @@ public class InterpreterCompletion implements org.apache.thrift.TBase<Interprete
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_name = true && (isSetName());
list.add(present_name);
builder.append(present_name);
if (present_name)
list.add(name);
builder.append(name);
boolean present_value = true && (isSetValue());
list.add(present_value);
builder.append(present_value);
if (present_value)
list.add(value);
builder.append(value);
return list.hashCode();
return builder.toHashCode();
}
@Override

View file

@ -1,11 +1,29 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.zeppelin.interpreter.thrift;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
@ -29,12 +47,9 @@ import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-11-18")
public class RemoteApplicationResult implements org.apache.thrift.TBase<RemoteApplicationResult, RemoteApplicationResult._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteApplicationResult> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteApplicationResult");
@ -291,19 +306,19 @@ public class RemoteApplicationResult implements org.apache.thrift.TBase<RemoteAp
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_success = true;
list.add(present_success);
builder.append(present_success);
if (present_success)
list.add(success);
builder.append(success);
boolean present_msg = true && (isSetMsg());
list.add(present_msg);
builder.append(present_msg);
if (present_msg)
list.add(msg);
builder.append(msg);
return list.hashCode();
return builder.toHashCode();
}
@Override

View file

@ -1,11 +1,29 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.zeppelin.interpreter.thrift;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
@ -29,12 +47,9 @@ import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-11-18")
public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteInterpreterContext, RemoteInterpreterContext._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteInterpreterContext> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterContext");
@ -702,54 +717,54 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_noteId = true && (isSetNoteId());
list.add(present_noteId);
builder.append(present_noteId);
if (present_noteId)
list.add(noteId);
builder.append(noteId);
boolean present_paragraphId = true && (isSetParagraphId());
list.add(present_paragraphId);
builder.append(present_paragraphId);
if (present_paragraphId)
list.add(paragraphId);
builder.append(paragraphId);
boolean present_replName = true && (isSetReplName());
list.add(present_replName);
builder.append(present_replName);
if (present_replName)
list.add(replName);
builder.append(replName);
boolean present_paragraphTitle = true && (isSetParagraphTitle());
list.add(present_paragraphTitle);
builder.append(present_paragraphTitle);
if (present_paragraphTitle)
list.add(paragraphTitle);
builder.append(paragraphTitle);
boolean present_paragraphText = true && (isSetParagraphText());
list.add(present_paragraphText);
builder.append(present_paragraphText);
if (present_paragraphText)
list.add(paragraphText);
builder.append(paragraphText);
boolean present_authenticationInfo = true && (isSetAuthenticationInfo());
list.add(present_authenticationInfo);
builder.append(present_authenticationInfo);
if (present_authenticationInfo)
list.add(authenticationInfo);
builder.append(authenticationInfo);
boolean present_config = true && (isSetConfig());
list.add(present_config);
builder.append(present_config);
if (present_config)
list.add(config);
builder.append(config);
boolean present_gui = true && (isSetGui());
list.add(present_gui);
builder.append(present_gui);
if (present_gui)
list.add(gui);
builder.append(gui);
boolean present_runners = true && (isSetRunners());
list.add(present_runners);
builder.append(present_runners);
if (present_runners)
list.add(runners);
builder.append(runners);
return list.hashCode();
return builder.toHashCode();
}
@Override

View file

@ -1,11 +1,29 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.zeppelin.interpreter.thrift;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
@ -29,12 +47,9 @@ import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-11-18")
public class RemoteInterpreterEvent implements org.apache.thrift.TBase<RemoteInterpreterEvent, RemoteInterpreterEvent._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteInterpreterEvent> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterEvent");
@ -305,19 +320,19 @@ public class RemoteInterpreterEvent implements org.apache.thrift.TBase<RemoteInt
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_type = true && (isSetType());
list.add(present_type);
builder.append(present_type);
if (present_type)
list.add(type.getValue());
builder.append(type.getValue());
boolean present_data = true && (isSetData());
list.add(present_data);
builder.append(present_data);
if (present_data)
list.add(data);
builder.append(data);
return list.hashCode();
return builder.toHashCode();
}
@Override
@ -428,7 +443,7 @@ public class RemoteInterpreterEvent implements org.apache.thrift.TBase<RemoteInt
switch (schemeField.id) {
case 1: // TYPE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.type = org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventType.findByValue(iprot.readI32());
struct.type = RemoteInterpreterEventType.findByValue(iprot.readI32());
struct.setTypeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
@ -505,7 +520,7 @@ public class RemoteInterpreterEvent implements org.apache.thrift.TBase<RemoteInt
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.type = org.apache.zeppelin.interpreter.thrift.RemoteInterpreterEventType.findByValue(iprot.readI32());
struct.type = RemoteInterpreterEventType.findByValue(iprot.readI32());
struct.setTypeIsSet(true);
}
if (incoming.get(1)) {

View file

@ -1,5 +1,22 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated

View file

@ -1,11 +1,29 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.zeppelin.interpreter.thrift;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
@ -29,12 +47,9 @@ import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2016-11-18")
public class RemoteInterpreterResult implements org.apache.thrift.TBase<RemoteInterpreterResult, RemoteInterpreterResult._Fields>, java.io.Serializable, Cloneable, Comparable<RemoteInterpreterResult> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterResult");
@ -466,34 +481,34 @@ public class RemoteInterpreterResult implements org.apache.thrift.TBase<RemoteIn
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_code = true && (isSetCode());
list.add(present_code);
builder.append(present_code);
if (present_code)
list.add(code);
builder.append(code);
boolean present_type = true && (isSetType());
list.add(present_type);
builder.append(present_type);
if (present_type)
list.add(type);
builder.append(type);
boolean present_msg = true && (isSetMsg());
list.add(present_msg);
builder.append(present_msg);
if (present_msg)
list.add(msg);
builder.append(msg);
boolean present_config = true && (isSetConfig());
list.add(present_config);
builder.append(present_config);
if (present_config)
list.add(config);
builder.append(config);
boolean present_gui = true && (isSetGui());
list.add(present_gui);
builder.append(present_gui);
if (present_gui)
list.add(gui);
builder.append(gui);
return list.hashCode();
return builder.toHashCode();
}
@Override

View file

@ -75,8 +75,8 @@ struct InterpreterCompletion {
}
service RemoteInterpreterService {
void createInterpreter(1: string intpGroupId, 2: string sessionKey, 3: string className, 4: map<string, string> properties);
void createInterpreter(1: string intpGroupId, 2: string sessionKey, 3: string className, 4: map<string, string> properties, 5: string userName);
void open(1: string sessionKey, 2: string className);
void close(1: string sessionKey, 2: string className);
RemoteInterpreterResult interpret(1: string sessionKey, 2: string className, 3: string st, 4: RemoteInterpreterContext interpreterContext);

View file

@ -19,7 +19,7 @@
rm -rf gen-java
rm -rf ../java/org/apache/zeppelin/interpreter/thrift
thrift --gen java RemoteInterpreterService.thrift
thrift --gen java:hashcode RemoteInterpreterService.thrift
for file in gen-java/org/apache/zeppelin/interpreter/thrift/* ; do
cat java_license_header.txt ${file} > ${file}.tmp
mv -f ${file}.tmp ${file}