use of org.apache.commons.io.output.ByteArrayOutputStream in project Gargoyle by callakrsos.
the class JavaProcessMonitor method menuThreadDumpOnAction.
/**
* Thread Dump
* @작성자 : KYJ
* @작성일 : 2017. 1. 23.
* @param e
* @throws Exception
*/
public void menuThreadDumpOnAction(ActionEvent e) {
ApplicationModel selectedItem = getSelectedItem(item -> item);
if (selectedItem == null) {
Window window = FxUtil.getWindow(this.getParent(), () -> {
return SharedMemory.getPrimaryStage();
});
DialogUtil.showMessageDialog(window, "덤프를 출력할 프로세스를 선택.");
return;
}
Integer selectedProcessId = selectedItem.getProcessId();
String applicationName = selectedItem.getApplicationName();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Monitors.runStackTool(selectedProcessId, out);
ThreadDumpTextArea parent = new ThreadDumpTextArea();
parent.setContent(out.toString());
FxUtil.createStageAndShow(parent, stage -> {
stage.initOwner(getParent().getScene().getWindow());
stage.setWidth(1200d);
stage.setHeight(800d);
stage.setTitle("App - " + applicationName);
});
// FxUtil.createSimpleTextAreaAndShow(out.toString(), stage -> {
//
//
// });
}
use of org.apache.commons.io.output.ByteArrayOutputStream in project SSM by Intel-bigdata.
the class TestCheckStorageAction method testCheckStorageAction.
@Test
public void testCheckStorageAction() throws IOException {
CheckStorageAction checkStorageAction = new CheckStorageAction();
checkStorageAction.setDfsClient(dfsClient);
checkStorageAction.setContext(smartContext);
final String file = "/testParallelMovers/file1";
dfsClient.mkdirs("/testParallelMovers");
// write to HDFS
final OutputStream out = dfsClient.create(file, true);
byte[] content = ("This is a file containing two blocks" + "......................").getBytes();
out.write(content);
out.close();
// do CheckStorageAction
checkStorageAction.init(new String[] { file });
checkStorageAction.run();
ActionStatus actionStatus = checkStorageAction.getActionStatus();
System.out.println(StringUtils.formatTime(actionStatus.getRunningTime()));
Assert.assertTrue(actionStatus.isFinished());
Assert.assertTrue(actionStatus.isSuccessful());
Assert.assertEquals(1.0f, actionStatus.getPercentage(), 0.00001f);
ByteArrayOutputStream resultStream = actionStatus.getResultStream();
System.out.println(resultStream);
}
use of org.apache.commons.io.output.ByteArrayOutputStream in project sling by apache.
the class DistributionPackageUtilsTest method testInfoFullStreams.
@Test
public void testInfoFullStreams() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Map<String, Object> info = new HashMap<String, Object>();
info.put("test1", "value1");
info.put("test2", "value2");
info.put("test3", new String[] { "value1", "value2" });
DistributionPackageUtils.writeInfo(outputStream, info);
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
Map<String, Object> resultInfo = new HashMap<String, Object>();
DistributionPackageUtils.readInfo(inputStream, resultInfo);
assertEquals(info.size(), resultInfo.size());
assertEquals("value1", resultInfo.get("test1"));
assertEquals("value2", resultInfo.get("test2"));
String[] array = (String[]) resultInfo.get("test3");
assertEquals("value1", array[0]);
assertEquals("value2", array[1]);
}
use of org.apache.commons.io.output.ByteArrayOutputStream in project metron by apache.
the class SerDeUtils method toBytes.
/**
* Serialize a profile measurement's value.
*
* The value produced by a Profile definition can be any numeric data type. The data
* type depends on how the profile is defined by the user. The user should be able to
* choose the data type that is most suitable for their use case.
*
* @param value The value to serialize.
*/
public static byte[] toBytes(Object value) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Output output = new Output(bos);
kryo.get().writeClassAndObject(output, value);
output.flush();
bos.flush();
return bos.toByteArray();
} catch (Throwable t) {
LOG.error("Unable to serialize: {} because {}", value, t.getMessage(), t);
throw new IllegalStateException("Unable to serialize " + value + " because " + t.getMessage(), t);
}
}
use of org.apache.commons.io.output.ByteArrayOutputStream in project syncany by syncany.
the class ApplicationLink method getPlaintextStorageXml.
private byte[] getPlaintextStorageXml() throws Exception {
ByteArrayOutputStream plaintextByteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream plaintextOutputStream = new DataOutputStream(plaintextByteArrayOutputStream);
plaintextOutputStream.writeInt(transferSettings.getType().getBytes().length);
plaintextOutputStream.write(transferSettings.getType().getBytes());
GZIPOutputStream plaintextGzipOutputStream = new GZIPOutputStream(plaintextOutputStream);
new Persister(new Format(0)).write(transferSettings, plaintextGzipOutputStream);
plaintextGzipOutputStream.close();
return plaintextByteArrayOutputStream.toByteArray();
}
Aggregations