use of com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter in project coprhd-controller by CoprHD.
the class LogNetworkReaderPerfTest method testPerformance.
@Test
public void testPerformance() throws Exception {
List<String> svcs = new ArrayList<String>() {
{
add("controllersvc");
add("coordinatorsvc");
add("apisvc");
}
};
int bufSize = 1024 * 64;
LogRequest req = new LogRequest.Builder().baseNames(svcs).build();
final LogNetworkWriter writer = new LogNetworkWriter(req, propertiesLoader);
try (final PipedOutputStream out = new PipedOutputStream();
final BufferedOutputStream outputStream = new BufferedOutputStream(out, bufSize);
final PipedInputStream inputStream = new PipedInputStream(out)) {
LogNetworkReader reader = new LogNetworkReader("vipr1", "vipr1", inputStream, new LogStatusInfo());
long totalSize = 0;
long startTime = System.nanoTime();
new Thread(new Runnable() {
public void run() {
try {
writer.write(outputStream);
} catch (Exception e) {
// NOSONAR
e.printStackTrace();
// ("squid:S1148 suppress sonar warning on printStackTrace. It's a test case and exceptions are meant to be printed to stdout/stderr")
}
}
}).start();
LogMessage log = null;
while ((log = reader.readNextLogMessage()) != null) {
totalSize += log.toStringOriginalFormat().getBytes().length;
}
long endTime = System.nanoTime();
totalSize /= (1024L * 1024L);
double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
System.out.println("Total read " + totalSize + " MB;" + " Used " + elapsedTime + " sec; Average " + (totalSize / elapsedTime) + " MB/sec.");
}
}
use of com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter in project coprhd-controller by CoprHD.
the class LogNetworkWriterPerfTest method testPerformance.
@Test
public void testPerformance() throws Exception {
List<String> svcs = new ArrayList<String>() {
{
add("controllersvc");
add("coordinatorsvc");
add("apisvc");
}
};
LogRequest req = new LogRequest.Builder().baseNames(svcs).build();
LogNetworkWriter writer = new LogNetworkWriter(req, propertiesLoader);
ByteCountingOutputStream outputStream = new ByteCountingOutputStream();
long startTime = System.nanoTime();
writer.write(outputStream);
long endTime = System.nanoTime();
long totalSize = outputStream.getSize() / (1024L * 1024L);
double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
System.out.println("Total read " + totalSize + " MB;" + " Used " + elapsedTime + " sec; Average " + (totalSize / elapsedTime) + " MB/sec.");
}
use of com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter in project coprhd-controller by CoprHD.
the class LogService method getNodeLogs.
/**
* Internal Use
* <p/>
* Gets a chunk of the log data from the Bourne node to which the request is directed that is filtered, merged, and sorted based on the
* passed request parameters. The log messages are returned as a JSON formatted string.
*
* @return A Response containing the log messages as a JSON formatted
* string.
*/
@POST
@Path("internal/node-logs/")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response getNodeLogs(LogRequest logReqInfo) {
_log.trace("Enter into getNodeLogs()");
if (logReqInfo.isDryRun()) {
return Response.ok().build();
}
final LogNetworkWriter logRequestMgr = new LogNetworkWriter(logReqInfo, _logSvcPropertiesLoader);
StreamingOutput logMsgStream = new StreamingOutput() {
@Override
public void write(OutputStream outputStream) throws IOException, WebApplicationException {
logRequestMgr.write(outputStream);
}
};
return Response.ok(logMsgStream).build();
}
Aggregations