use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.
the class ClusterSystemPluginResource method list.
@GET
@Timed
@ApiOperation(value = "List all installed plugins on the given node")
public PluginList list(@ApiParam(name = "nodeId", value = "The id of the node where processing will be paused.", required = true) @PathParam("nodeId") String nodeId) throws IOException, NodeNotFoundException {
final Node targetNode = nodeService.byNodeId(nodeId);
final RemoteSystemPluginResource remoteSystemPluginResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteSystemPluginResource.class);
final Response<PluginList> response = remoteSystemPluginResource.list().execute();
if (response.isSuccessful()) {
return response.body();
} else {
LOG.warn("Unable to get plugin list on node {}: {}", nodeId, response.message());
throw new WebApplicationException(response.message(), BAD_GATEWAY);
}
}
use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.
the class ClusterSystemResource method jvm.
@GET
@Timed
@ApiOperation(value = "Get JVM information of the given node")
@Path("{nodeId}/jvm")
public SystemJVMResponse jvm(@ApiParam(name = "nodeId", value = "The id of the node to retrieve JVM information.", required = true) @PathParam("nodeId") String nodeId) throws IOException, NodeNotFoundException {
final Node targetNode = nodeService.byNodeId(nodeId);
final RemoteSystemResource remoteSystemResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteSystemResource.class);
final Response<SystemJVMResponse> response = remoteSystemResource.jvm().execute();
if (response.isSuccessful()) {
return response.body();
} else {
LOG.warn("Unable to get jvm information on node {}: {}", nodeId, response.message());
throw new WebApplicationException(response.message(), BAD_GATEWAY);
}
}
use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.
the class ClusterSystemShutdownResource method shutdown.
@POST
@Timed
@AuditEvent(type = AuditEventTypes.NODE_SHUTDOWN_INITIATE)
public void shutdown(@PathParam("nodeId") String nodeId) throws IOException, NodeNotFoundException {
LOG.warn("Deprecated API endpoint /cluster/{nodeId}/shutdown was called. Shutting down nodes via the API is " + "discouraged in favor of using a service manager to control the server process.");
final Node targetNode = nodeService.byNodeId(nodeId);
RemoteSystemShutdownResource remoteSystemShutdownResource = remoteInterfaceProvider.get(targetNode, this.authenticationToken, RemoteSystemShutdownResource.class);
final Response response = remoteSystemShutdownResource.shutdown().execute();
if (response.code() != ACCEPTED.getStatusCode()) {
LOG.warn("Unable send shut down signal to node {}: {}", nodeId, response.message());
throw new WebApplicationException(response.message(), BAD_GATEWAY);
}
}
use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.
the class ClusterLoggersResource method setSubsystemLoggerLevel.
@PUT
@Timed
@Path("/{nodeId}/subsystems/{subsystem}/level/{level}")
@ApiOperation(value = "Set the loglevel of a whole subsystem", notes = "Provided level is falling back to DEBUG if it does not exist")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such subsystem.") })
@NoAuditEvent("proxy resource, audit event will be emitted on target nodes")
public void setSubsystemLoggerLevel(@ApiParam(name = "nodeId", required = true) @PathParam("nodeId") @NotEmpty String nodeId, @ApiParam(name = "subsystem", required = true) @PathParam("subsystem") @NotEmpty String subsystemTitle, @ApiParam(name = "level", required = true) @PathParam("level") @NotEmpty String level) throws NodeNotFoundException, IOException {
final Node node = this.nodeService.byNodeId(nodeId);
final RemoteLoggersResource remoteLoggersResource = this.remoteInterfaceProvider.get(node, this.authenticationToken, RemoteLoggersResource.class);
remoteLoggersResource.setSubsystemLoggerLevel(subsystemTitle, level).execute();
}
use of org.graylog2.cluster.NodeNotFoundException in project graylog2-server by Graylog2.
the class NodePingThread method doRun.
@Override
public synchronized // This method is "synchronized" because we are also calling it directly in AutomaticLeaderElectionService
void doRun() {
final boolean isLeader = leaderElectionService.isLeader();
try {
Node node = nodeService.byNodeId(serverStatus.getNodeId());
nodeService.markAsAlive(node, isLeader, httpConfiguration.getHttpPublishUri().resolve(HttpConfiguration.PATH_API));
} catch (NodeNotFoundException e) {
LOG.warn("Did not find meta info of this node. Re-registering.");
nodeService.registerServer(serverStatus.getNodeId().toString(), isLeader, httpConfiguration.getHttpPublishUri().resolve(HttpConfiguration.PATH_API), Tools.getLocalCanonicalHostname());
}
try {
// Remove old nodes that are no longer running. (Just some housekeeping)
nodeService.dropOutdated();
// Check that we still have a leader node in the cluster, if not, warn the user.
if (nodeService.isAnyLeaderPresent()) {
if (fixNoLeaderNotification()) {
activityWriter.write(new Activity("Notification condition [" + NotificationImpl.Type.NO_LEADER + "] " + "has been fixed.", NodePingThread.class));
}
} else {
Notification notification = notificationService.buildNow().addNode(serverStatus.getNodeId().toString()).addType(Notification.Type.NO_LEADER).addSeverity(Notification.Severity.URGENT);
notificationService.publishIfFirst(notification);
}
} catch (Exception e) {
LOG.warn("Caught exception during node ping.", e);
}
}
Aggregations