use of org.apache.zeppelin.cluster.event.ClusterMessage in project zeppelin by apache.
the class AuthorizationService method broadcastClusterEvent.
// broadcast cluster event
private void broadcastClusterEvent(ClusterEvent event, String noteId, String user, Set<String> set) {
if (!conf.isClusterMode()) {
return;
}
ClusterMessage message = new ClusterMessage(event);
message.put("noteId", noteId);
message.put("user", user);
Gson gson = new Gson();
String json = gson.toJson(set, new TypeToken<Set<String>>() {
}.getType());
message.put("set", json);
String msg = ClusterMessage.serializeMessage(message);
ClusterManagerServer.getInstance(conf).broadcastClusterEvent(ClusterManagerServer.CLUSTER_AUTH_EVENT_TOPIC, msg);
}
use of org.apache.zeppelin.cluster.event.ClusterMessage in project zeppelin by apache.
the class AuthorizationService method onClusterEvent.
@Override
public void onClusterEvent(String msg) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("onClusterEvent : {}", msg);
}
ClusterMessage message = ClusterMessage.deserializeMessage(msg);
String noteId = message.get("noteId");
String user = message.get("user");
String jsonSet = message.get("set");
Gson gson = new Gson();
Set<String> set = gson.fromJson(jsonSet, new TypeToken<Set<String>>() {
}.getType());
try {
switch(message.clusterEvent) {
case SET_READERS_PERMISSIONS:
setReaders(noteId, set, false);
break;
case SET_WRITERS_PERMISSIONS:
setWriters(noteId, set, false);
break;
case SET_OWNERS_PERMISSIONS:
setOwners(noteId, set, false);
break;
case SET_RUNNERS_PERMISSIONS:
setRunners(noteId, set, false);
break;
case SET_ROLES:
setRoles(user, set, false);
break;
case CLEAR_PERMISSION:
clearPermission(noteId, false);
break;
default:
LOGGER.error("Unknown clusterEvent:{}, msg:{} ", message.clusterEvent, msg);
break;
}
} catch (IOException e) {
LOGGER.warn("Fail to broadcast msg", e);
}
}
use of org.apache.zeppelin.cluster.event.ClusterMessage in project zeppelin by apache.
the class InterpreterSettingManager method onClusterEvent.
@Override
public void onClusterEvent(String msg) {
LOGGER.debug("onClusterEvent : {}", msg);
try {
ClusterMessage message = ClusterMessage.deserializeMessage(msg);
String jsonIntpSetting = message.get("intpSetting");
InterpreterSetting intpSetting = InterpreterSetting.fromJson(jsonIntpSetting);
String id = intpSetting.getId();
String name = intpSetting.getName();
String group = intpSetting.getGroup();
InterpreterOption option = intpSetting.getOption();
HashMap<String, InterpreterProperty> properties = (HashMap<String, InterpreterProperty>) InterpreterSetting.convertInterpreterProperties(intpSetting.getProperties());
List<Dependency> dependencies = intpSetting.getDependencies();
switch(message.clusterEvent) {
case CREATE_INTP_SETTING:
inlineCreateNewSetting(name, group, dependencies, option, properties);
break;
case UPDATE_INTP_SETTING:
inlineSetPropertyAndRestart(id, option, properties, dependencies, false);
break;
case DELETE_INTP_SETTING:
inlineRemove(id, false);
break;
default:
LOGGER.error("Unknown clusterEvent:{}, msg:{} ", message.clusterEvent, msg);
break;
}
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
} catch (InterpreterException e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.apache.zeppelin.cluster.event.ClusterMessage in project zeppelin by apache.
the class ClusterIntpSettingEventListenerTest method onClusterEvent.
@Override
public void onClusterEvent(String msg) {
receiveMsg = msg;
LOGGER.info("ClusterIntpSettingEventListenerTest#onClusterEvent : {}", msg);
ClusterMessage message = ClusterMessage.deserializeMessage(msg);
}
Aggregations