use of com.emc.vipr.model.sys.logging.LogLevels in project coprhd-controller by CoprHD.
the class LogLevelManager method propagate.
// Building the internal log URI for each node and calling using client
// Collecting streams from all nodes - if any node does not send response,
// logging error.
private LogLevels propagate(List<NodeInfo> nodeInfos, List<String> logNames, LogSeverity severity, int expirInMin, String scope) {
LogLevels nodeLogLevels = new LogLevels();
for (final NodeInfo node : nodeInfos) {
String baseNodeURL = String.format(BASE_URL_FORMAT, node.getIpAddress(), node.getPort());
_log.debug("processing node: " + baseNodeURL);
SysClientFactory.SysClient sysClient = SysClientFactory.getSysClient(URI.create(baseNodeURL), _propertiesLoader.getNodeLogCollectorTimeout() * 1000, _propertiesLoader.getNodeLogConnectionTimeout() * 1000);
try {
LogLevelRequest nodeLogReqInfo = new LogLevelRequest(new ArrayList<String>() {
{
add(node.getId());
}
}, logNames, severity, expirInMin, scope);
LogLevels nodeResp = sysClient.post(SysClientFactory.URI_LOG_LEVELS, LogLevels.class, nodeLogReqInfo);
nodeLogLevels.getLogLevels().addAll(nodeResp.getLogLevels());
} catch (Exception e) {
_log.error("Exception accessing node {}:", baseNodeURL, e);
}
}
return nodeLogLevels;
}
use of com.emc.vipr.model.sys.logging.LogLevels in project coprhd-controller by CoprHD.
the class LogService method processNodeLogLevel.
/**
* Internal Use
* <p/>
* Gets/sets the log level of the Bourne node to which the request is directed that is filtered based on the passed request paramters.
*
* @return A Response containing the log levels for each service specified
* in the request.
*/
@POST
@Path("internal/log-level/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public LogLevels processNodeLogLevel(LogLevelRequest logReqInfo) throws WebApplicationException {
String nodeId = logReqInfo.getNodeIds().get(0);
LogLevels logLevels = new LogLevels();
// filter the log names list
List<String> logNames = logReqInfo.getLogNames();
List<String> availableLogNames = ServicesMetadata.getRoleServiceNames(_coordinatorClientExt.getNodeRoles());
if (logNames.isEmpty()) {
logNames = new ArrayList<String>(availableLogNames);
} else {
logNames.retainAll(availableLogNames);
}
logNames.removeAll(_exemptLogSvcs);
boolean isGetReq = false;
if (logReqInfo.getSeverity() == LogSeverity.NA) {
isGetReq = true;
}
for (String logName : logNames) {
if (isGetReq) {
_log.info("getting log level from service {}", logName);
} else {
_log.info("setting log level of service {}", logName);
}
try {
String level = null;
if (isGetReq) {
level = LoggingOps.getLevel(logName);
_log.debug("log level of service {} is {}", logName, level);
String nodeName = _coordinatorClientExt.getMatchingNodeName(nodeId);
logLevels.getLogLevels().add(new LogLevels.LogLevel(nodeId, nodeName, logName, level));
} else {
// set logger level
level = logReqInfo.getSeverity().toString();
LoggingOps.setLevel(logName, level, logReqInfo.getExpirInMin(), logReqInfo.getScope());
_log.debug("log level of service {} has been set to {}", logName, level);
}
} catch (IllegalStateException e) {
if (isGetReq) {
_log.error("Failed to get log level from service {}:", logName, e);
} else {
_log.error("Failed to set log level of service {}:", logName, e);
}
}
}
return logLevels;
}
use of com.emc.vipr.model.sys.logging.LogLevels in project coprhd-controller by CoprHD.
the class Logs method getLogLevels.
/**
* Gets the log levels for the given nodes and logs.
*
* @param nodeIds
* the IDs of the nodes. If null or empty, all node log levels are retrieved
* @param logNames
* the name of the logs. If null or empty, all logs' levels are returned.
* @return the list of log levels.
* @deprecated Replaced by
* @see #getLogLevels(Collection, Collection, Collection)
*/
public List<LogLevel> getLogLevels(Collection<String> nodeIds, Collection<String> logNames) {
UriBuilder builder = client.uriBuilder(PathConstants.LOG_LEVELS_URL);
if ((nodeIds != null) && (!nodeIds.isEmpty())) {
builder.queryParam(NODE_ID, nodeIds.toArray());
}
if ((logNames != null) && (!logNames.isEmpty())) {
builder.queryParam(LOG_NAME, logNames.toArray());
}
LogLevels response = client.getURI(LogLevels.class, builder.build());
return response.getLogLevels();
}
Aggregations