use of org.apache.storm.utils.WrappedNotAliveException in project storm by apache.
the class Supervisor method createSupervisorIface.
private org.apache.storm.generated.Supervisor.Iface createSupervisorIface() {
return new org.apache.storm.generated.Supervisor.Iface() {
@Override
public void sendSupervisorAssignments(SupervisorAssignments assignments) throws AuthorizationException, TException {
checkAuthorization("sendSupervisorAssignments");
LOG.info("Got an assignments from master, will start to sync with assignments: {}", assignments);
SynchronizeAssignments syn = new SynchronizeAssignments(getSupervisor(), assignments, getReadClusterState());
getEventManger().add(syn);
}
@Override
public Assignment getLocalAssignmentForStorm(String id) throws NotAliveException, AuthorizationException, TException {
Map<String, Object> topoConf = null;
try {
topoConf = ConfigUtils.readSupervisorStormConf(conf, id);
} catch (IOException e) {
LOG.warn("Topology config is not localized yet...");
}
checkAuthorization(id, topoConf, "getLocalAssignmentForStorm");
Assignment assignment = getStormClusterState().assignmentInfo(id, null);
if (null == assignment) {
throw new WrappedNotAliveException("No local assignment assigned for storm: " + id + " for node: " + getHostName());
}
return assignment;
}
@Override
public void sendSupervisorWorkerHeartbeat(SupervisorWorkerHeartbeat heartbeat) throws AuthorizationException, NotAliveException, TException {
// do nothing except validate heartbeat for now.
String id = heartbeat.get_storm_id();
Map<String, Object> topoConf = null;
try {
topoConf = ConfigUtils.readSupervisorStormConf(conf, id);
} catch (IOException e) {
LOG.warn("Topology config is not localized yet...");
throw new WrappedNotAliveException(id + " does not appear to be alive, you should probably exit");
}
checkAuthorization(id, topoConf, "sendSupervisorWorkerHeartbeat");
}
};
}
use of org.apache.storm.utils.WrappedNotAliveException in project storm by apache.
the class Nimbus method getTopologyInfoByNameImpl.
private TopologyInfo getTopologyInfoByNameImpl(String name, GetInfoOptions options) throws NotAliveException, AuthorizationException, Exception {
IStormClusterState state = stormClusterState;
String id = state.getTopoId(name).orElseThrow(() -> new WrappedNotAliveException(name + " is not alive"));
return getTopologyInfoWithOptsImpl(id, options);
}
use of org.apache.storm.utils.WrappedNotAliveException in project storm by apache.
the class Nimbus method getTopologySummary.
@Override
public TopologySummary getTopologySummary(String id) throws NotAliveException, AuthorizationException, TException {
try {
getTopologySummaryCalls.mark();
IStormClusterState state = stormClusterState;
StormBase base = state.topologyBases().get(id);
if (base == null) {
throw new WrappedNotAliveException(id + " is not alive");
}
checkAuthorization(base.get_name(), null, "getTopologySummary");
return getTopologySummaryImpl(id, base);
} catch (Exception e) {
LOG.warn("Get TopologySummaryById info exception.", e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
use of org.apache.storm.utils.WrappedNotAliveException in project storm by apache.
the class Nimbus method debug.
@Override
public void debug(String topoName, String componentId, boolean enable, double samplingPercentage) throws NotAliveException, AuthorizationException, TException {
debugCalls.mark();
try {
IStormClusterState state = stormClusterState;
String topoId = toTopoId(topoName);
Map<String, Object> topoConf = tryReadTopoConf(topoId, topoCache);
topoConf = Utils.merge(conf, topoConf);
// make sure samplingPct is within bounds.
double spct = Math.max(Math.min(samplingPercentage, 100.0), 0.0);
// while disabling we retain the sampling pct.
checkAuthorization(topoName, topoConf, "debug");
if (topoId == null) {
throw new WrappedNotAliveException(topoName);
}
DebugOptions options = new DebugOptions();
options.set_enable(enable);
if (enable) {
options.set_samplingpct(spct);
}
StormBase updates = new StormBase();
// For backwards compatability
updates.set_component_executors(Collections.emptyMap());
boolean hasCompId = componentId != null && !componentId.isEmpty();
String key = hasCompId ? componentId : topoId;
updates.put_to_component_debug(key, options);
LOG.info("Nimbus setting debug to {} for storm-name '{}' storm-id '{}' sanpling pct '{}'" + (hasCompId ? " component-id '" + componentId + "'" : ""), enable, topoName, topoId, spct);
synchronized (submitLock) {
state.updateStorm(topoId, updates);
}
} catch (Exception e) {
LOG.warn("debug topology exception. (topology name='{}')", topoName, e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
Aggregations