Added the close of metrics files
This commit is contained in:
@@ -104,8 +104,9 @@ public class ConsumerFuture implements Runnable {
|
|||||||
m_benchMarkOut.close();
|
m_benchMarkOut.close();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileWriter fw = new FileWriter(BENCHMARK_FILE);
|
FileOutputStream fw = new FileOutputStream(BENCHMARK_FILE);
|
||||||
fw.write(m_baos.toString());
|
fw.write(m_baos.toByteArray());
|
||||||
|
fw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ public class Producer implements Runnable {
|
|||||||
|
|
||||||
public static final int PUB_LOOP = 100000;
|
public static final int PUB_LOOP = 100000;
|
||||||
|
|
||||||
private static int m_starIndex;
|
private int m_starIndex;
|
||||||
private static int m_len;
|
private int m_len;
|
||||||
private long m_startMillis;
|
private long m_startMillis;
|
||||||
private static final String BENCHMARK_FILE = "producer_bechmark.txt";
|
private static final String BENCHMARK_FILE = "producer_bechmark_%s.txt";
|
||||||
private PrintWriter m_benchMarkOut;
|
private PrintWriter m_benchMarkOut;
|
||||||
private ByteArrayOutputStream m_baos = new ByteArrayOutputStream(1024 * 1024);
|
private ByteArrayOutputStream m_baos = new ByteArrayOutputStream(1024 * 1024 * 2);
|
||||||
|
|
||||||
public Producer(String clientID, int start, int len) {
|
public Producer(String clientID, int start, int len) {
|
||||||
m_clientID = clientID;
|
m_clientID = clientID;
|
||||||
@@ -60,6 +60,7 @@ public class Producer implements Runnable {
|
|||||||
long time = System.currentTimeMillis() - m_startMillis;
|
long time = System.currentTimeMillis() - m_startMillis;
|
||||||
LOG.info(String.format("Producer %s connected in %d ms", Thread.currentThread().getName(), time));
|
LOG.info(String.format("Producer %s connected in %d ms", Thread.currentThread().getName(), time));
|
||||||
|
|
||||||
|
LOG.info("Starting from index " + m_starIndex + " up to " + (m_starIndex + m_len));
|
||||||
m_startMillis = System.currentTimeMillis();
|
m_startMillis = System.currentTimeMillis();
|
||||||
for (int i = m_starIndex; i < m_starIndex + m_len; i++) {
|
for (int i = m_starIndex; i < m_starIndex + m_len; i++) {
|
||||||
try {
|
try {
|
||||||
@@ -88,11 +89,13 @@ public class Producer implements Runnable {
|
|||||||
time = System.currentTimeMillis() - m_startMillis;
|
time = System.currentTimeMillis() - m_startMillis;
|
||||||
LOG.info(String.format("Producer %s disconnected in %d ms", Thread.currentThread().getName(), time));
|
LOG.info(String.format("Producer %s disconnected in %d ms", Thread.currentThread().getName(), time));
|
||||||
|
|
||||||
|
m_benchMarkOut.flush();
|
||||||
m_benchMarkOut.close();
|
m_benchMarkOut.close();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileWriter fw = new FileWriter(BENCHMARK_FILE);
|
FileOutputStream fw = new FileOutputStream(String.format(BENCHMARK_FILE, m_clientID));
|
||||||
fw.write(m_baos.toString());
|
fw.write(m_baos.toByteArray());
|
||||||
|
fw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user