use of org.apache.zeppelin.cluster.event.ClusterEvent in project zeppelin by apache.
the class ClusterInterpreterLauncher method onClusterEvent.
@Override
public void onClusterEvent(String msg) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(msg);
}
try {
Gson gson = new Gson();
Map<String, Object> mapEvent = gson.fromJson(msg, new TypeToken<Map<String, Object>>() {
}.getType());
String sEvent = (String) mapEvent.get(CLUSTER_EVENT);
ClusterEvent clusterEvent = ClusterEvent.valueOf(sEvent);
switch(clusterEvent) {
case CREATE_INTP_PROCESS:
// 1)Other zeppelin servers in the cluster send requests to create an interpreter process
// 2)After the interpreter process is created, and the interpreter is started,
// the interpreter registers the thrift ip and port into the cluster metadata.
// 3)Other servers connect through the IP and port of thrift in the cluster metadata,
// using this remote interpreter process
String eventMsg = (String) mapEvent.get(CLUSTER_EVENT_MSG);
InterpreterLaunchContext context = gson.fromJson(eventMsg, new TypeToken<InterpreterLaunchContext>() {
}.getType());
InterpreterClient intpProcess = createInterpreterProcess(context);
intpProcess.start(context.getUserName());
break;
default:
LOGGER.error("Unknown clusterEvent:{}, msg:{} ", clusterEvent, msg);
break;
}
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
}
Aggregations