userName to be present in InterpreterContext/RemoteInterpreterContext

This commit is contained in:
Prabhjyot Singh 2016-02-08 21:59:13 +05:30
parent 9b461ad246
commit fadc6d92ff
25 changed files with 306 additions and 165 deletions

View file

@ -33,6 +33,6 @@ user2 = password3
# anon means the access is anonymous.
# authcBasic means Basic Auth Security
# To enfore security, comment the line below and uncomment the next one
/** = anon
#/** = authcBasic
#/** = anon
/** = authcBasic

View file

@ -40,7 +40,7 @@ public class FlinkInterpreterTest {
Properties p = new Properties();
flink = new FlinkInterpreter(p);
flink.open();
context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null);
context = new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null);
}
@AfterClass

View file

@ -79,9 +79,9 @@ public class HiveInterpreterTest {
HiveInterpreter t = new HiveInterpreter(properties);
t.open();
assertTrue(t.interpret("show databases", new InterpreterContext("", "1", "","", null,null,null,null,null,null)).message().contains("SCHEMA_NAME"));
assertTrue(t.interpret("show databases", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)).message().contains("SCHEMA_NAME"));
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n",
t.interpret("select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null)).message());
t.interpret("select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)).message());
}
@Test
@ -101,7 +101,7 @@ public class HiveInterpreterTest {
t.open();
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n",
t.interpret("(h2)\n select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null)).message());
t.interpret("(h2)\n select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null)).message());
}
@Test
@ -117,13 +117,13 @@ public class HiveInterpreterTest {
t.open();
InterpreterResult interpreterResult =
t.interpret("select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null));
t.interpret("select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null));
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", interpreterResult.message());
t.getConnection("default").close();
interpreterResult =
t.interpret("select * from test_table", new InterpreterContext("", "1", "","", null,null,null,null,null,null));
t.interpret("select * from test_table", new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null));
assertEquals("ID\tNAME\na\ta_name\nb\tb_name\n", interpreterResult.message());
}
@ -139,7 +139,7 @@ public class HiveInterpreterTest {
HiveInterpreter t = new HiveInterpreter(properties);
t.open();
InterpreterContext interpreterContext = new InterpreterContext(null, "a", null, null, null, null, null, null, null, null);
InterpreterContext interpreterContext = new InterpreterContext(null, "a", null, null, null, null, null, null, null, null, null);
//simple select test
InterpreterResult result = t.interpret("select * from test_table", interpreterContext);

View file

@ -40,7 +40,7 @@ public class IgniteInterpreterTest {
private static final String HOST = "127.0.0.1:47500..47509";
private static final InterpreterContext INTP_CONTEXT =
new InterpreterContext(null, null, null, null, null, null, null, null, null, null);
new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null);
private IgniteInterpreter intp;
private Ignite ignite;

View file

@ -44,7 +44,7 @@ public class IgniteSqlInterpreterTest {
private static final String HOST = "127.0.0.1:47500..47509";
private static final InterpreterContext INTP_CONTEXT =
new InterpreterContext(null, null, null, null, null, null, null, null, null, null);
new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null);
private Ignite ignite;
private IgniteSqlInterpreter intp;

View file

@ -94,7 +94,7 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
String sqlQuery = "select * from test_table";
InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null));
InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null));
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
@ -116,7 +116,7 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
String sqlQuery = "select * from test_table";
InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "","", null,null,null,null,null,null));
InterpreterResult interpreterResult = t.interpret(sqlQuery, new InterpreterContext("", "1", "", "", null, null, null, null, null, null, null));
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());

View file

@ -58,7 +58,7 @@ public class DepInterpreterTest {
intpGroup.add(dep);
dep.setInterpreterGroup(intpGroup);
context = new InterpreterContext("note", "id", "title", "text", new HashMap<String, Object>(), new GUI(),
context = new InterpreterContext("note", "id", "title", "text", null, new HashMap<String, Object>(), new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
null,
new LinkedList<InterpreterContextRunner>(), null);

View file

@ -76,22 +76,23 @@ public class SparkInterpreterTest {
InterpreterGroup intpGroup = new InterpreterGroup();
context = new InterpreterContext("note", "id", "title", "text",
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
null,
new LinkedList<InterpreterContextRunner>(),
new InterpreterOutput(new InterpreterOutputListener() {
@Override
public void onAppend(InterpreterOutput out, byte[] line) {
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
null,
new LinkedList<InterpreterContextRunner>(),
new InterpreterOutput(new InterpreterOutputListener() {
@Override
public void onAppend(InterpreterOutput out, byte[] line) {
}
}
@Override
public void onUpdate(InterpreterOutput out, byte[] output) {
@Override
public void onUpdate(InterpreterOutput out, byte[] output) {
}
}));
}
}));
}
@After

View file

@ -65,7 +65,7 @@ public class SparkSqlInterpreterTest {
sql.setInterpreterGroup(intpGroup);
sql.open();
}
context = new InterpreterContext("note", "id", "title", "text", new HashMap<String, Object>(), new GUI(),
context = new InterpreterContext("note", "id", "title", "text", null, new HashMap<String, Object>(), new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
null,
new LinkedList<InterpreterContextRunner>(), new InterpreterOutput(new InterpreterOutputListener() {

View file

@ -32,7 +32,7 @@ trait AbstractAngularElemTest
override def beforeEach() {
val intpGroup = new InterpreterGroup()
val context = new InterpreterContext("note", "paragraph", "title", "text",
val context = new InterpreterContext("note", "paragraph", "title", "text", null,
new util.HashMap[String, Object](), new GUI(), new AngularObjectRegistry(
intpGroup.getId(), null),
null,

View file

@ -28,7 +28,7 @@ trait AbstractAngularModelTest extends FlatSpec
with BeforeAndAfter with BeforeAndAfterEach with Eventually with Matchers {
override def beforeEach() {
val intpGroup = new InterpreterGroup()
val context = new InterpreterContext("note", "id", "title", "text",
val context = new InterpreterContext("note", "id", "title", "text", null,
new java.util.HashMap[String, Object](), new GUI(), new AngularObjectRegistry(
intpGroup.getId(), null),
null,

View file

@ -48,6 +48,7 @@ public class InterpreterContext {
private final String paragraphTitle;
private final String paragraphId;
private final String paragraphText;
private final String user;
private final Map<String, Object> config;
private GUI gui;
private AngularObjectRegistry angularObjectRegistry;
@ -58,6 +59,7 @@ public class InterpreterContext {
String paragraphId,
String paragraphTitle,
String paragraphText,
String user,
Map<String, Object> config,
GUI gui,
AngularObjectRegistry angularObjectRegistry,
@ -69,6 +71,7 @@ public class InterpreterContext {
this.paragraphId = paragraphId;
this.paragraphTitle = paragraphTitle;
this.paragraphText = paragraphText;
this.user = user;
this.config = config;
this.gui = gui;
this.angularObjectRegistry = angularObjectRegistry;
@ -94,6 +97,10 @@ public class InterpreterContext {
return paragraphTitle;
}
public String getUser() {
return user;
}
public Map<String, Object> getConfig() {
return config;
}

View file

@ -364,6 +364,7 @@ public class RemoteInterpreter extends Interpreter {
ic.getParagraphId(),
ic.getParagraphTitle(),
ic.getParagraphText(),
ic.getUser(),
gson.toJson(ic.getConfig()),
gson.toJson(ic.getGui()),
gson.toJson(ic.getRunners()));

View file

@ -392,6 +392,7 @@ public class RemoteInterpreterServer
ric.getParagraphId(),
ric.getParagraphTitle(),
ric.getParagraphText(),
ric.getUser(),
(Map<String, Object>) gson.fromJson(ric.getConfig(),
new TypeToken<Map<String, Object>>() {}.getType()),
gson.fromJson(ric.getGui(), GUI.class),

View file

@ -59,9 +59,10 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
private static final org.apache.thrift.protocol.TField PARAGRAPH_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphId", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField PARAGRAPH_TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphTitle", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField PARAGRAPH_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphText", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final org.apache.thrift.protocol.TField CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("config", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final org.apache.thrift.protocol.TField GUI_FIELD_DESC = new org.apache.thrift.protocol.TField("gui", org.apache.thrift.protocol.TType.STRING, (short)6);
private static final org.apache.thrift.protocol.TField RUNNERS_FIELD_DESC = new org.apache.thrift.protocol.TField("runners", org.apache.thrift.protocol.TType.STRING, (short)7);
private static final org.apache.thrift.protocol.TField USER_FIELD_DESC = new org.apache.thrift.protocol.TField("user", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final org.apache.thrift.protocol.TField CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("config", org.apache.thrift.protocol.TType.STRING, (short)6);
private static final org.apache.thrift.protocol.TField GUI_FIELD_DESC = new org.apache.thrift.protocol.TField("gui", org.apache.thrift.protocol.TType.STRING, (short)7);
private static final org.apache.thrift.protocol.TField RUNNERS_FIELD_DESC = new org.apache.thrift.protocol.TField("runners", org.apache.thrift.protocol.TType.STRING, (short)8);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -73,6 +74,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
public String paragraphId; // required
public String paragraphTitle; // required
public String paragraphText; // required
public String user; // required
public String config; // required
public String gui; // required
public String runners; // required
@ -83,9 +85,10 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
PARAGRAPH_ID((short)2, "paragraphId"),
PARAGRAPH_TITLE((short)3, "paragraphTitle"),
PARAGRAPH_TEXT((short)4, "paragraphText"),
CONFIG((short)5, "config"),
GUI((short)6, "gui"),
RUNNERS((short)7, "runners");
USER((short)5, "user"),
CONFIG((short)6, "config"),
GUI((short)7, "gui"),
RUNNERS((short)8, "runners");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -108,11 +111,13 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
return PARAGRAPH_TITLE;
case 4: // PARAGRAPH_TEXT
return PARAGRAPH_TEXT;
case 5: // CONFIG
case 5: // USER
return USER;
case 6: // CONFIG
return CONFIG;
case 6: // GUI
case 7: // GUI
return GUI;
case 7: // RUNNERS
case 8: // RUNNERS
return RUNNERS;
default:
return null;
@ -157,19 +162,21 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.NOTE_ID, new org.apache.thrift.meta_data.FieldMetaData("noteId", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.NOTE_ID, new org.apache.thrift.meta_data.FieldMetaData("noteId", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.PARAGRAPH_ID, new org.apache.thrift.meta_data.FieldMetaData("paragraphId", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.PARAGRAPH_ID, new org.apache.thrift.meta_data.FieldMetaData("paragraphId", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.PARAGRAPH_TITLE, new org.apache.thrift.meta_data.FieldMetaData("paragraphTitle", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.PARAGRAPH_TITLE, new org.apache.thrift.meta_data.FieldMetaData("paragraphTitle", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.PARAGRAPH_TEXT, new org.apache.thrift.meta_data.FieldMetaData("paragraphText", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.PARAGRAPH_TEXT, new org.apache.thrift.meta_data.FieldMetaData("paragraphText", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CONFIG, new org.apache.thrift.meta_data.FieldMetaData("config", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.USER, new org.apache.thrift.meta_data.FieldMetaData("user", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.GUI, new org.apache.thrift.meta_data.FieldMetaData("gui", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.CONFIG, new org.apache.thrift.meta_data.FieldMetaData("config", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.RUNNERS, new org.apache.thrift.meta_data.FieldMetaData("runners", org.apache.thrift.TFieldRequirementType.DEFAULT,
tmpMap.put(_Fields.GUI, new org.apache.thrift.meta_data.FieldMetaData("gui", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.RUNNERS, new org.apache.thrift.meta_data.FieldMetaData("runners", 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(RemoteInterpreterContext.class, metaDataMap);
@ -179,19 +186,21 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
}
public RemoteInterpreterContext(
String noteId,
String paragraphId,
String paragraphTitle,
String paragraphText,
String config,
String gui,
String runners)
String noteId,
String paragraphId,
String paragraphTitle,
String paragraphText,
String user,
String config,
String gui,
String runners)
{
this();
this.noteId = noteId;
this.paragraphId = paragraphId;
this.paragraphTitle = paragraphTitle;
this.paragraphText = paragraphText;
this.user = user;
this.config = config;
this.gui = gui;
this.runners = runners;
@ -213,6 +222,9 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (other.isSetParagraphText()) {
this.paragraphText = other.paragraphText;
}
if (other.isSetUser()) {
this.user = other.user;
}
if (other.isSetConfig()) {
this.config = other.config;
}
@ -234,6 +246,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
this.paragraphId = null;
this.paragraphTitle = null;
this.paragraphText = null;
this.user = null;
this.config = null;
this.gui = null;
this.runners = null;
@ -335,6 +348,30 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
}
}
public String getUser() {
return this.user;
}
public RemoteInterpreterContext setUser(String user) {
this.user = user;
return this;
}
public void unsetUser() {
this.user = null;
}
/** Returns true if field user is set (has been assigned a value) and false otherwise */
public boolean isSetUser() {
return this.user != null;
}
public void setUserIsSet(boolean value) {
if (!value) {
this.user = null;
}
}
public String getConfig() {
return this.config;
}
@ -409,87 +446,98 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NOTE_ID:
if (value == null) {
unsetNoteId();
} else {
setNoteId((String)value);
}
break;
case NOTE_ID:
if (value == null) {
unsetNoteId();
} else {
setNoteId((String)value);
}
break;
case PARAGRAPH_ID:
if (value == null) {
unsetParagraphId();
} else {
setParagraphId((String)value);
}
break;
case PARAGRAPH_ID:
if (value == null) {
unsetParagraphId();
} else {
setParagraphId((String)value);
}
break;
case PARAGRAPH_TITLE:
if (value == null) {
unsetParagraphTitle();
} else {
setParagraphTitle((String)value);
}
break;
case PARAGRAPH_TITLE:
if (value == null) {
unsetParagraphTitle();
} else {
setParagraphTitle((String)value);
}
break;
case PARAGRAPH_TEXT:
if (value == null) {
unsetParagraphText();
} else {
setParagraphText((String)value);
}
break;
case PARAGRAPH_TEXT:
if (value == null) {
unsetParagraphText();
} else {
setParagraphText((String)value);
}
break;
case CONFIG:
if (value == null) {
unsetConfig();
} else {
setConfig((String)value);
}
break;
case USER:
if (value == null) {
unsetUser();
} else {
setUser((String) value);
}
break;
case GUI:
if (value == null) {
unsetGui();
} else {
setGui((String)value);
}
break;
case CONFIG:
if (value == null) {
unsetConfig();
} else {
setConfig((String)value);
}
break;
case RUNNERS:
if (value == null) {
unsetRunners();
} else {
setRunners((String)value);
}
break;
case GUI:
if (value == null) {
unsetGui();
} else {
setGui((String)value);
}
break;
case RUNNERS:
if (value == null) {
unsetRunners();
} else {
setRunners((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case NOTE_ID:
return getNoteId();
case NOTE_ID:
return getNoteId();
case PARAGRAPH_ID:
return getParagraphId();
case PARAGRAPH_ID:
return getParagraphId();
case PARAGRAPH_TITLE:
return getParagraphTitle();
case PARAGRAPH_TITLE:
return getParagraphTitle();
case PARAGRAPH_TEXT:
return getParagraphText();
case PARAGRAPH_TEXT:
return getParagraphText();
case CONFIG:
return getConfig();
case USER:
return getUser();
case GUI:
return getGui();
case CONFIG:
return getConfig();
case RUNNERS:
return getRunners();
case GUI:
return getGui();
case RUNNERS:
return getRunners();
}
throw new IllegalStateException();
@ -502,20 +550,22 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
}
switch (field) {
case NOTE_ID:
return isSetNoteId();
case PARAGRAPH_ID:
return isSetParagraphId();
case PARAGRAPH_TITLE:
return isSetParagraphTitle();
case PARAGRAPH_TEXT:
return isSetParagraphText();
case CONFIG:
return isSetConfig();
case GUI:
return isSetGui();
case RUNNERS:
return isSetRunners();
case NOTE_ID:
return isSetNoteId();
case PARAGRAPH_ID:
return isSetParagraphId();
case PARAGRAPH_TITLE:
return isSetParagraphTitle();
case PARAGRAPH_TEXT:
return isSetParagraphText();
case USER:
return isSetUser();
case CONFIG:
return isSetConfig();
case GUI:
return isSetGui();
case RUNNERS:
return isSetRunners();
}
throw new IllegalStateException();
}
@ -569,6 +619,15 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
return false;
}
boolean this_present_user = true && this.isSetUser();
boolean that_present_user = true && that.isSetUser();
if (this_present_user || that_present_user) {
if (!(this_present_user && that_present_user))
return false;
if (!this.user.equals(that.user))
return false;
}
boolean this_present_config = true && this.isSetConfig();
boolean that_present_config = true && that.isSetConfig();
if (this_present_config || that_present_config) {
@ -623,6 +682,11 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (present_paragraphText)
list.add(paragraphText);
boolean present_user = true && (isSetUser());
list.add(present_user);
if (present_user)
list.add(user);
boolean present_config = true && (isSetConfig());
list.add(present_config);
if (present_config)
@ -689,6 +753,16 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetUser()).compareTo(other.isSetUser());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUser()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.user, other.user);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetConfig()).compareTo(other.isSetConfig());
if (lastComparison != 0) {
return lastComparison;
@ -771,6 +845,14 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
}
first = false;
if (!first) sb.append(", ");
sb.append("user:");
if (this.user == null) {
sb.append("null");
} else {
sb.append(this.user);
}
first = false;
if (!first) sb.append(", ");
sb.append("config:");
if (this.config == null) {
sb.append("null");
@ -833,7 +915,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@ -841,7 +923,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.noteId = iprot.readString();
struct.setNoteIdIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -849,7 +931,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.paragraphId = iprot.readString();
struct.setParagraphIdIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -857,7 +939,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.paragraphTitle = iprot.readString();
struct.setParagraphTitleIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -865,31 +947,39 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.paragraphText = iprot.readString();
struct.setParagraphTextIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // CONFIG
case 5: // USER
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.user = iprot.readString();
struct.setUserIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 6: // CONFIG
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.config = iprot.readString();
struct.setConfigIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 6: // GUI
case 7: // GUI
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.gui = iprot.readString();
struct.setGuiIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 7: // RUNNERS
case 8: // RUNNERS
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.runners = iprot.readString();
struct.setRunnersIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -928,6 +1018,11 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
oprot.writeString(struct.paragraphText);
oprot.writeFieldEnd();
}
if (struct.user != null) {
oprot.writeFieldBegin(USER_FIELD_DESC);
oprot.writeString(struct.user);
oprot.writeFieldEnd();
}
if (struct.config != null) {
oprot.writeFieldBegin(CONFIG_FIELD_DESC);
oprot.writeString(struct.config);
@ -973,16 +1068,19 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (struct.isSetParagraphText()) {
optionals.set(3);
}
if (struct.isSetConfig()) {
if (struct.isSetUser()) {
optionals.set(4);
}
if (struct.isSetGui()) {
if (struct.isSetConfig()) {
optionals.set(5);
}
if (struct.isSetRunners()) {
if (struct.isSetGui()) {
optionals.set(6);
}
oprot.writeBitSet(optionals, 7);
if (struct.isSetRunners()) {
optionals.set(7);
}
oprot.writeBitSet(optionals, 8);
if (struct.isSetNoteId()) {
oprot.writeString(struct.noteId);
}
@ -995,6 +1093,9 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
if (struct.isSetParagraphText()) {
oprot.writeString(struct.paragraphText);
}
if (struct.isSetUser()) {
oprot.writeString(struct.user);
}
if (struct.isSetConfig()) {
oprot.writeString(struct.config);
}
@ -1009,7 +1110,7 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterContext struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(7);
BitSet incoming = iprot.readBitSet(8);
if (incoming.get(0)) {
struct.noteId = iprot.readString();
struct.setNoteIdIsSet(true);
@ -1027,14 +1128,18 @@ public class RemoteInterpreterContext implements org.apache.thrift.TBase<RemoteI
struct.setParagraphTextIsSet(true);
}
if (incoming.get(4)) {
struct.user = iprot.readString();
struct.setUserIsSet(true);
}
if (incoming.get(5)) {
struct.config = iprot.readString();
struct.setConfigIsSet(true);
}
if (incoming.get(5)) {
if (incoming.get(6)) {
struct.gui = iprot.readString();
struct.setGuiIsSet(true);
}
if (incoming.get(6)) {
if (incoming.get(7)) {
struct.runners = iprot.readString();
struct.setRunnersIsSet(true);
}

View file

@ -24,9 +24,10 @@ struct RemoteInterpreterContext {
2: string paragraphId,
3: string paragraphTitle,
4: string paragraphText,
5: string config, // json serialized config
6: string gui, // json serialized gui
7: string runners // json serialized runner
5: string user,
6: string config, // json serialized config
7: string gui, // json serialized gui
8: string runners // json serialized runner
}
struct RemoteInterpreterResult {

View file

@ -27,7 +27,7 @@ public class InterpreterContextTest {
public void testThreadLocal() {
assertNull(InterpreterContext.get());
InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null, null, null));
InterpreterContext.set(new InterpreterContext(null, null, null, null, null, null, null, null, null, null, null));
assertNotNull(InterpreterContext.get());
InterpreterContext.remove();

View file

@ -84,6 +84,7 @@ public class RemoteAngularObjectTest implements AngularObjectRegistryListener {
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),

View file

@ -75,6 +75,7 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),

View file

@ -121,6 +121,7 @@ public class RemoteInterpreterTest {
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -155,6 +156,7 @@ public class RemoteInterpreterTest {
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -204,6 +206,7 @@ public class RemoteInterpreterTest {
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -217,6 +220,7 @@ public class RemoteInterpreterTest {
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -269,6 +273,7 @@ public class RemoteInterpreterTest {
"jobA",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -304,6 +309,7 @@ public class RemoteInterpreterTest {
"jobB",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -370,6 +376,7 @@ public class RemoteInterpreterTest {
jobId,
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -448,6 +455,7 @@ public class RemoteInterpreterTest {
jobId,
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -547,6 +555,7 @@ public class RemoteInterpreterTest {
"jobA",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),

View file

@ -93,6 +93,7 @@ public class DistributedResourcePoolTest {
"id",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
null,

View file

@ -103,6 +103,7 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
"jobId",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -175,6 +176,7 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
"jobId1",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),
@ -212,6 +214,7 @@ public class RemoteSchedulerTest implements RemoteInterpreterProcessListener {
"jobId2",
"title",
"text",
null,
new HashMap<String, Object>(),
new GUI(),
new AngularObjectRegistry(intpGroup.getId(), null),

View file

@ -16,20 +16,13 @@
*/
package org.apache.zeppelin.socket;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.servlet.http.HttpServletRequest;
import com.google.common.base.Strings;
import com.google.gson.Gson;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
import org.apache.zeppelin.display.AngularObject;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.AngularObjectRegistryListener;
import org.apache.zeppelin.display.Input;
import org.apache.zeppelin.interpreter.InterpreterOutput;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterSetting;
@ -37,7 +30,6 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcessListener;
import org.apache.zeppelin.notebook.*;
import org.apache.zeppelin.scheduler.Job;
import org.apache.zeppelin.scheduler.Job.Status;
import org.apache.zeppelin.scheduler.JobListener;
import org.apache.zeppelin.server.ZeppelinServer;
import org.apache.zeppelin.socket.Message.OP;
import org.apache.zeppelin.ticket.TicketContainer;
@ -48,8 +40,12 @@ import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
import com.google.gson.Gson;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* Zeppelin websocket service.
@ -693,6 +689,10 @@ public class NotebookServer extends WebSocketServlet implements
String text = (String) fromMessage.get("paragraph");
p.setText(text);
p.setTitle((String) fromMessage.get("title"));
if (!fromMessage.principal.equals("anonymous")) {
p.setUser(fromMessage.principal);
}
Map<String, Object> params = (Map<String, Object>) fromMessage
.get("params");
p.settings.setParams(params);

View file

@ -45,6 +45,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
String title;
String text;
String user;
Date dateUpdated;
private Map<String, Object> config; // paragraph configs like isOpen, colWidth, etc
public final GUI settings; // form and parameter settings
@ -55,6 +56,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
this.replLoader = replLoader;
title = null;
text = null;
user = null;
dateUpdated = null;
settings = new GUI();
config = new HashMap<String, Object>();
@ -74,6 +76,13 @@ public class Paragraph extends Job implements Serializable, Cloneable {
this.dateUpdated = new Date();
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getTitle() {
return title;
@ -276,6 +285,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
getId(),
this.getTitle(),
this.getText(),
this.getUser(),
this.getConfig(),
this.settings,
registry,

View file

@ -62,7 +62,7 @@ public class InterpreterFactoryTest {
conf = new ZeppelinConfiguration();
depResolver = new DependencyResolver(tmpDir.getAbsolutePath() + "/local-repo");
factory = new InterpreterFactory(conf, new InterpreterOption(false), null, null, depResolver);
context = new InterpreterContext("note", "id", "title", "text", null, null, null, null, null, null);
context = new InterpreterContext("note", "id", "title", "text", null, null, null, null, null, null, null);
}