Merge remote-tracking branch 'origin/master' into ZEPPELIN-212

This commit is contained in:
Lee moon soo 2016-11-29 20:50:49 -08:00
commit 0c6a13c3a8
8 changed files with 141 additions and 22 deletions

View file

@ -105,11 +105,12 @@ Server will be run on [http://localhost:8080](http://localhost:8080).
Some portions of the Zeppelin code are generated by [Thrift](http://thrift.apache.org). For most Zeppelin changes, you don't need to worry about this. But if you modify any of the Thrift IDL files (e.g. zeppelin-interpreter/src/main/thrift/*.thrift), then you also need to regenerate these files and submit their updated version as part of your patch.
To regenerate the code, install **thrift-0.9.2** and change directory into Zeppelin source directory. and then run following command
To regenerate the code, install **thrift-0.9.2** and then run the following command to generate thrift code.
```
thrift -out zeppelin-interpreter/src/main/java/ --gen java zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift
cd <zeppelin_home>/zeppelin-interpreter/src/main/thrift
./genthrift.sh
```
## Where to Start

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

@ -240,8 +240,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

@ -155,10 +155,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);
@ -196,6 +195,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

@ -56,7 +56,7 @@ public class RemoteInterpreterService {
public interface Iface {
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties) throws org.apache.thrift.TException;
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, String userName) throws org.apache.thrift.TException;
public void open(String sessionKey, String className) throws org.apache.thrift.TException;
@ -108,7 +108,7 @@ public class RemoteInterpreterService {
public interface AsyncIface {
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, String userName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
public void open(String sessionKey, String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
@ -178,19 +178,20 @@ public class RemoteInterpreterService {
super(iprot, oprot);
}
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties) throws org.apache.thrift.TException
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, String userName) throws org.apache.thrift.TException
{
send_createInterpreter(intpGroupId, sessionKey, className, properties);
send_createInterpreter(intpGroupId, sessionKey, className, properties, userName);
recv_createInterpreter();
}
public void send_createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties) throws org.apache.thrift.TException
public void send_createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, String userName) throws org.apache.thrift.TException
{
createInterpreter_args args = new createInterpreter_args();
args.setIntpGroupId(intpGroupId);
args.setSessionKey(sessionKey);
args.setClassName(className);
args.setProperties(properties);
args.setUserName(userName);
sendBase("createInterpreter", args);
}
@ -742,9 +743,9 @@ public class RemoteInterpreterService {
super(protocolFactory, clientManager, transport);
}
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
public void createInterpreter(String intpGroupId, String sessionKey, String className, Map<String,String> properties, String userName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
checkReady();
createInterpreter_call method_call = new createInterpreter_call(intpGroupId, sessionKey, className, properties, resultHandler, this, ___protocolFactory, ___transport);
createInterpreter_call method_call = new createInterpreter_call(intpGroupId, sessionKey, className, properties, userName, resultHandler, this, ___protocolFactory, ___transport);
this.___currentMethod = method_call;
___manager.call(method_call);
}
@ -754,12 +755,14 @@ public class RemoteInterpreterService {
private String sessionKey;
private String className;
private Map<String,String> properties;
public createInterpreter_call(String intpGroupId, String sessionKey, String className, Map<String,String> properties, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
private String userName;
public createInterpreter_call(String intpGroupId, String sessionKey, String className, Map<String,String> properties, String userName, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
super(client, protocolFactory, transport, resultHandler, false);
this.intpGroupId = intpGroupId;
this.sessionKey = sessionKey;
this.className = className;
this.properties = properties;
this.userName = userName;
}
public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@ -769,6 +772,7 @@ public class RemoteInterpreterService {
args.setSessionKey(sessionKey);
args.setClassName(className);
args.setProperties(properties);
args.setUserName(userName);
args.write(prot);
prot.writeMessageEnd();
}
@ -1655,7 +1659,7 @@ public class RemoteInterpreterService {
public createInterpreter_result getResult(I iface, createInterpreter_args args) throws org.apache.thrift.TException {
createInterpreter_result result = new createInterpreter_result();
iface.createInterpreter(args.intpGroupId, args.sessionKey, args.className, args.properties);
iface.createInterpreter(args.intpGroupId, args.sessionKey, args.className, args.properties, args.userName);
return result;
}
}
@ -2208,7 +2212,7 @@ public class RemoteInterpreterService {
}
public void start(I iface, createInterpreter_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws TException {
iface.createInterpreter(args.intpGroupId, args.sessionKey, args.className, args.properties,resultHandler);
iface.createInterpreter(args.intpGroupId, args.sessionKey, args.className, args.properties, args.userName,resultHandler);
}
}
@ -3385,6 +3389,7 @@ public class RemoteInterpreterService {
private static final org.apache.thrift.protocol.TField SESSION_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionKey", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)4);
private static final org.apache.thrift.protocol.TField USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("userName", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -3396,13 +3401,15 @@ public class RemoteInterpreterService {
public String sessionKey; // required
public String className; // required
public Map<String,String> properties; // required
public String userName; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
INTP_GROUP_ID((short)1, "intpGroupId"),
SESSION_KEY((short)2, "sessionKey"),
CLASS_NAME((short)3, "className"),
PROPERTIES((short)4, "properties");
PROPERTIES((short)4, "properties"),
USER_NAME((short)5, "userName");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -3425,6 +3432,8 @@ public class RemoteInterpreterService {
return CLASS_NAME;
case 4: // PROPERTIES
return PROPERTIES;
case 5: // USER_NAME
return USER_NAME;
default:
return null;
}
@ -3478,6 +3487,8 @@ public class RemoteInterpreterService {
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
tmpMap.put(_Fields.USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("userName", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createInterpreter_args.class, metaDataMap);
}
@ -3489,13 +3500,15 @@ public class RemoteInterpreterService {
String intpGroupId,
String sessionKey,
String className,
Map<String,String> properties)
Map<String,String> properties,
String userName)
{
this();
this.intpGroupId = intpGroupId;
this.sessionKey = sessionKey;
this.className = className;
this.properties = properties;
this.userName = userName;
}
/**
@ -3515,6 +3528,9 @@ public class RemoteInterpreterService {
Map<String,String> __this__properties = new HashMap<String,String>(other.properties);
this.properties = __this__properties;
}
if (other.isSetUserName()) {
this.userName = other.userName;
}
}
public createInterpreter_args deepCopy() {
@ -3527,6 +3543,7 @@ public class RemoteInterpreterService {
this.sessionKey = null;
this.className = null;
this.properties = null;
this.userName = null;
}
public String getIntpGroupId() {
@ -3636,6 +3653,30 @@ public class RemoteInterpreterService {
}
}
public String getUserName() {
return this.userName;
}
public createInterpreter_args setUserName(String userName) {
this.userName = userName;
return this;
}
public void unsetUserName() {
this.userName = null;
}
/** Returns true if field userName is set (has been assigned a value) and false otherwise */
public boolean isSetUserName() {
return this.userName != null;
}
public void setUserNameIsSet(boolean value) {
if (!value) {
this.userName = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case INTP_GROUP_ID:
@ -3670,6 +3711,14 @@ public class RemoteInterpreterService {
}
break;
case USER_NAME:
if (value == null) {
unsetUserName();
} else {
setUserName((String)value);
}
break;
}
}
@ -3687,6 +3736,9 @@ public class RemoteInterpreterService {
case PROPERTIES:
return getProperties();
case USER_NAME:
return getUserName();
}
throw new IllegalStateException();
}
@ -3706,6 +3758,8 @@ public class RemoteInterpreterService {
return isSetClassName();
case PROPERTIES:
return isSetProperties();
case USER_NAME:
return isSetUserName();
}
throw new IllegalStateException();
}
@ -3759,6 +3813,15 @@ public class RemoteInterpreterService {
return false;
}
boolean this_present_userName = true && this.isSetUserName();
boolean that_present_userName = true && that.isSetUserName();
if (this_present_userName || that_present_userName) {
if (!(this_present_userName && that_present_userName))
return false;
if (!this.userName.equals(that.userName))
return false;
}
return true;
}
@ -3786,6 +3849,11 @@ public class RemoteInterpreterService {
if (present_properties)
list.add(properties);
boolean present_userName = true && (isSetUserName());
list.add(present_userName);
if (present_userName)
list.add(userName);
return list.hashCode();
}
@ -3837,6 +3905,16 @@ public class RemoteInterpreterService {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetUserName()).compareTo(other.isSetUserName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUserName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userName, other.userName);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -3888,6 +3966,14 @@ public class RemoteInterpreterService {
sb.append(this.properties);
}
first = false;
if (!first) sb.append(", ");
sb.append("userName:");
if (this.userName == null) {
sb.append("null");
} else {
sb.append(this.userName);
}
first = false;
sb.append(")");
return sb.toString();
}
@ -3975,6 +4061,14 @@ public class RemoteInterpreterService {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // USER_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.userName = iprot.readString();
struct.setUserNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -4018,6 +4112,11 @@ public class RemoteInterpreterService {
}
oprot.writeFieldEnd();
}
if (struct.userName != null) {
oprot.writeFieldBegin(USER_NAME_FIELD_DESC);
oprot.writeString(struct.userName);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -4048,7 +4147,10 @@ public class RemoteInterpreterService {
if (struct.isSetProperties()) {
optionals.set(3);
}
oprot.writeBitSet(optionals, 4);
if (struct.isSetUserName()) {
optionals.set(4);
}
oprot.writeBitSet(optionals, 5);
if (struct.isSetIntpGroupId()) {
oprot.writeString(struct.intpGroupId);
}
@ -4068,12 +4170,15 @@ public class RemoteInterpreterService {
}
}
}
if (struct.isSetUserName()) {
oprot.writeString(struct.userName);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, createInterpreter_args struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(4);
BitSet incoming = iprot.readBitSet(5);
if (incoming.get(0)) {
struct.intpGroupId = iprot.readString();
struct.setIntpGroupIdIsSet(true);
@ -4101,6 +4206,10 @@ public class RemoteInterpreterService {
}
struct.setPropertiesIsSet(true);
}
if (incoming.get(4)) {
struct.userName = iprot.readString();
struct.setUserNameIsSet(true);
}
}
}

View file

@ -86,8 +86,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);