+* 2.1.4
+- add monitoring emulator's start
+== jihye kim <jihye1128.kim@samsung.com> 2013-04-02
+
* 2.1.3
- modify module of open browser (tizendevelop site)
== jihye kim <jihye1128.kim@samsung.com> 2013-03-21
Source: emulator-manager
-Version: 2.1.3
+Version: 2.1.4
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
Package: emulator-manager
if (isConsoleMode) {
instance.startConsoleProcessor();
} else {
- EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!" + StringResource.NEW_LINE);
+ EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!");
instance.preare();
instance.DrawUI();
import org.tizen.emulator.manager.image.Platform;
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.tool.About;
+import org.tizen.emulator.manager.vms.CheckingRunningEmulator;
import org.tizen.emulator.manager.vms.EmulatorVMs;
import org.tizen.emulator.manager.vms.Launcher;
+import org.tizen.emulator.manager.vms.MonitoringEmulator;
import org.tizen.emulator.manager.vms.VMCreateHelper;
import org.tizen.emulator.manager.vms.VMsProperty;
import org.tizen.emulator.manager.vms.VMsWorkerException;
return false;
}
- if (launcher.launch(cmd)) {
- System.out.println("Success: To start emulator is completed.");
+ CheckingRunningEmulator.addEmulator(prop.getName());
+ MonitoringEmulator monitor = new MonitoringEmulator(prop);
+ Process process = launcher.launch(cmd);
+ if (process != null) {
+ monitor.setProcess(process, 5);
+ monitor.start();
+ try {
+ monitor.join();
+ } catch (InterruptedException e) {
+ System.out.println(e.getMessage());
+ }
+ if (monitor.isSuccess()) {
+ System.out.println("Success: To start emulator is completed.");
+ }
} else {
System.out.println("Error: Faile to start emulator.");
return false;
EMLogger.getLogger().warning(e.getMessage());
}
+ /*
try {
skinsList.add(new Skins(new File(FilePath.getInstance().getDataSkinPath())));
} catch (IOException e) {
EMLogger.getLogger().warning(e.getMessage());
}
+ */
for (Skins skins : skinsList) {
for (Skin s : skins.getSkinList()) {
process = pb.start();
process.waitFor();
exitValue = process.exitValue();
- EMLogger.getLogger().log(Level.INFO, "Check-hax.exe's exit value : " + exitValue);
+ EMLogger.getLogger().log(Level.INFO, "Check-hax.exe's exit value: " + exitValue);
} catch (IOException e) {
- EMLogger.getLogger().log(Level.INFO, "IOException" + e.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "IOException" + e.getMessage());
} catch (InterruptedException e) {
- EMLogger.getLogger().log(Level.INFO, "InterruptedException" + e.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "InterruptedException" + e.getMessage());
} catch (Exception e) {
- EMLogger.getLogger().log(Level.INFO, "Exception" + e.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "Exception" + e.getMessage());
}
if(exitValue == 0) {
process = pb.start();
process.waitFor();
exitValue = process.exitValue();
- EMLogger.getLogger().log(Level.WARNING, "'check-gl's exit value : " + exitValue);
+ EMLogger.getLogger().log(Level.INFO, "'check-gl's exit value: " + exitValue);
} catch (IOException e) {
EMLogger.getLogger().log(Level.WARNING, "IOException" + e.getMessage());
} catch (InterruptedException e) {
try {
inputStream = new FileInputStream(workspaceConfPath);
} catch (FileNotFoundException e1) {
- EMLogger.getLogger().log(Level.WARNING, "Faile to get current workspace: \n"+ e1.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "Faile to get current workspace:"
+ + StringResource.NEW_LINE + e1.getMessage());
createPropertyFile(workspaceConfPath);
return false;
}
try {
prop.load(inputStream);
} catch (IOException e) {
- EMLogger.getLogger().log(Level.WARNING, "Faile to get current workspace: \n" + e.getMessage());
+ EMLogger.getLogger().log(Level.WARNING, "Faile to get current workspace:"
+ + StringResource.NEW_LINE + e.getMessage());
result = false;
}
}
logger.log(Level.INFO, String.format(
- "Network name = %s, MAC = %s\n",
+ "Network name = %s, MAC = %s",
ni.getDisplayName(), macAddr));
}
} catch (SocketException e) {
logger.log(
Level.WARNING,
- String.format("Failed to get MAC address of host: %s\n",
+ String.format("Failed to get MAC address of host: %s",
e.getMessage()));
} catch (UnknownHostException e) {
logger.log(
Level.WARNING,
- String.format("Failed to get MAC address of host: %s\n",
+ String.format("Failed to get MAC address of host: %s",
e.getMessage()));
}
/* means both MAC_ADDRESS key and value are existed */
else {
logger.log(Level.INFO,
- String.format("Use original MAC = %s\n", macAddr));
+ String.format("Use original MAC = %s", macAddr));
}
if (workspacePath == null) {
if(!fi.mkdirs()) {
if (!EmulatorManager.isConsoleMode()) {
MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
- msg.openWarningDialog("Can not organize workspace. Aborting...\n" +
- "User do not have authority to use [" + path + "]");
+ msg.openWarningDialog("Can not organize workspace. Aborting..."
+ + StringResource.NEW_LINE
+ + "User do not have authority to use [" + path + "]");
}
- EMLogger.getLogger().log(Level.WARNING, "Can not organize workspace. Aborting...\n" +
- "User do not have authority to use [" + path + "]");
+ EMLogger.getLogger().log(Level.WARNING, "Can not organize workspace. Aborting..."
+ + StringResource.NEW_LINE
+ + "User do not have authority to use [" + path + "]");
EmulatorManager.exitEmulatorManager(-1);
}
}
package org.tizen.emulator.manager.vms;
-import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
CheckingRunningEmulator.addEmulator(property.getName());
MonitoringEmulator monitor = new MonitoringEmulator(property);
- if (launch(cmd)) {
+ Process process = launch(cmd);
+ if (process != null) {
+ monitor.setProcess(process);
monitor.start();
return true;
} else {
}
}
- public boolean launch(List<String> cmd) {
+ public Process launch(List<String> cmd) {
FilePath fio = FilePath.getInstance();
ProcessBuilder pb = new ProcessBuilder(cmd);
} else {
pb.directory(new File(this.binPath));
}
-
+ Process process = null;
try {
- Process process = pb.start();
-
- final InputStream in1 = new BufferedInputStream(process.getInputStream());
- final InputStream in2 = new BufferedInputStream(process.getErrorStream());
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- in1.read();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }).start();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- in2.read();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }).start();
-
+ process = pb.start();
} catch (IOException e) {
if (!isConsole) {
MessageDialog msg = new MessageDialog(new Shell(Display.getCurrent()));
msg.openWarningDialog("Failed to launch\n" + e.getMessage());
}
EMLogger.getLogger().log(Level.WARNING, "Failed to launch.\n" + e.getMessage());
- return false;
}
- return true;
- }
-}
-
-class MonitoringEmulator extends Thread {
- private VMsProperty property;
- public MonitoringEmulator(VMsProperty property) {
- this.property = property;
- this.setDaemon(true);
- }
-
- public void run() {
- boolean isChecking = false;
- for (int i = 0; i < 8 ; i++) {
- if (VMsWorker.checking(property)) {
- isChecking = true;
- CheckingRunningEmulator.removeEmulator(property.getName());
- break;
- }
-
- synchronized(this) {
- try {
- this.wait(1000);
- } catch (InterruptedException e) {
- EMLogger.getLogger().warning(e.getMessage());
- break;
- }
- }
- }
-
- if (!isChecking) {
- CheckingRunningEmulator.removeEmulator(property.getName());
- }
+ return process;
}
}
\ No newline at end of file
--- /dev/null
+package org.tizen.emulator.manager.vms;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.logging.EMLogger;
+import org.tizen.emulator.manager.tool.StringResource;
+import org.tizen.emulator.manager.ui.MessageDialog;
+
+public class MonitoringEmulator extends Thread {
+ private VMsProperty property;
+ private Process process;
+ private int count = 8;
+
+ public MonitoringEmulator(VMsProperty property) {
+ this.property = property;
+ this.setDaemon(true);
+ }
+
+ public void setProcess(Process process) {
+ this.process = process;
+ }
+
+ public void setProcess(Process process, int count) {
+ this.process = process;
+ this.count = count;
+ }
+
+ private BufferedReader readerOut = null;
+ private BufferedReader readerError = null;
+ private StdOut stdOut = null;
+ private StdOut stdErr = null;
+ private boolean success = true;
+
+ public void run() {
+ /*
+ boolean isChecking = false;
+ for (int i = 0; i < 8 ; i++) {
+ if (VMsWorker.checking(property)) {
+ isChecking = true;
+ CheckingRunningEmulator.removeEmulator(property.getName());
+ break;
+ }
+
+ synchronized(this) {
+ try {
+ this.wait(1000);
+ } catch (InterruptedException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ break;
+ }
+ }
+ }
+
+ if (!isChecking) {
+ CheckingRunningEmulator.removeEmulator(property.getName());
+ }
+ */
+ if (process == null || property == null) {
+ return;
+ }
+
+ InputStreamReader in1 = new InputStreamReader(process.getInputStream());
+ InputStreamReader in2 = new InputStreamReader(process.getErrorStream());
+ readerOut = new BufferedReader(in1);
+ readerError = new BufferedReader(in2);
+
+ stdOut = new StdOut(readerOut, property.getName());
+ stdErr = new StdOut(readerError, property.getName());
+
+ new Thread(stdOut).start();
+ new Thread(stdErr).start();
+
+ for (int i = 0; i < count; i++) {
+ try {
+ if (process.exitValue() != 0) {
+ setSuccess(false);
+ stdOut.printMessageList();
+ stdErr.printMessageList();
+ EMLogger.getLogger().warning("Emulator has been terminated. Exit value: " + process.exitValue()
+ + StringResource.NEW_LINE
+ + "You can see more information in the emulator-manager.log or "
+ + property.getName() + "'s logs directory.");
+ if (!EmulatorManager.isConsoleMode()) {
+ Display.getDefault().asyncExec(new Runnable(){
+
+ @Override
+ public void run() {
+ new MessageDialog().openWarningDialog("Emulator has been terminated."
+ + StringResource.NEW_LINE
+ + "You can see more information "
+ + StringResource.NEW_LINE
+ + "in the emulator-manager.log or "
+ + property.getName() + "'s logs directory.");
+ }
+
+ });
+ }
+ break;
+ } else {
+ EMLogger.getLogger().warning("Emulator has been terminated. Exit value: " + process.exitValue());
+ stdOut.printMessageList();
+ stdErr.printMessageList();
+ break;
+ }
+ } catch(IllegalThreadStateException e) {
+ // empty
+ //System.out.println(e.getMessage());
+ }
+
+ synchronized(this) {
+ try {
+ this.wait(1000);
+ } catch (InterruptedException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ break;
+ }
+ }
+ }
+
+ CheckingRunningEmulator.removeEmulator(property.getName());
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+}
+
+class StdOut implements Runnable {
+ private BufferedReader reader;
+ private String emName;
+ private final ArrayList<String> list = new ArrayList<String>();
+ public StdOut(BufferedReader reader, String name) {
+ this.reader = reader;
+ this.emName = name;
+ }
+
+ public StdOut(InputStreamReader in, String name) {
+ this.reader = new BufferedReader(in);
+ this.emName = name;
+ }
+
+ @ Override
+ public void run() {
+ String msg;
+ do {
+ try {
+ msg = reader.readLine();
+ list.add(msg);
+ } catch (IOException e) {
+ EMLogger.getLogger().info(e.getMessage());
+ }
+
+ } while (CheckingRunningEmulator.isContains(emName));
+ if (error) {
+ for (String s : list) {
+ if (s != null && !s.isEmpty()) {
+ EMLogger.getLogger().warning("Print Log From Emulator: " + s);
+ }
+ }
+ }
+ }
+
+ private boolean error = false;
+ public void printMessageList() {
+ error = true;
+ }
+}
}
if (!result) {
- logger.log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.\n");
+ logger.log(Level.INFO, "The same name of VM not exist anywhere. You can continue your job.");
}
return result;
} catch (IOException err) {