[Title] swap source upload
authorjooyoul_lee <jy.exe.lee@samsung.com>
Thu, 8 Aug 2013 02:07:45 +0000 (11:07 +0900)
committerjooyoul_lee <jy.exe.lee@samsung.com>
Thu, 8 Aug 2013 02:07:45 +0000 (11:07 +0900)
[Desc.]
[Issue]

13 files changed:
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerShellCommands.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/CommunicatorUtils.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/DACommunicator.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/logparser/LogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/SWAPLogParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/control/RunTimeConfiguration.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/data/BasicDataMessage.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/DataFactory.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/model/probe2/LogData.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/configuration/ConfigurationDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java

index 9b8d7fd..ba87f1f 100755 (executable)
@@ -41,7 +41,7 @@ public class AnalyzerShellCommands {
        public static final String DACOMMAND_RUN_EVENT = "da runevent";
        public static final String DACOMMAND_FIND_UNITTEST = "da findunittest";
        public static final String DACOMMAND_FIND_IME = "/usr/bin/pkginfo --arg-flt 10 http://tizen.org/category/ime";
-       public static final String DACOMMAND_CHECK_VERSION = "da checkversion";
+       public static final String DACOMMAND_CHECK_VERSION = "da getversion";
 
        public static final String CMD_IS_ARM_ARCH = "uname -m"; //$NON-NLS-1$
        public static final String CMD_CAT_PORT_FILE = "cat /tmp/port.da"; //$NON-NLS-1$
index 7690401..a80cd80 100755 (executable)
@@ -1,6 +1,5 @@
 package org.tizen.dynamicanalyzer.communicator;
 
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
 import static org.tizen.sdblib.util.DeviceUtil.isOnline;
 import static org.tizen.sdblib.util.IOUtil.tryClose;
 
@@ -32,7 +31,7 @@ import org.tizen.sdblib.service.SyncService;
 public class CommunicatorUtils {
        private static List<String> uploadDataResult = new ArrayList<String>();
        private static boolean isArch = false;
-       private static final int PORT_WAIT_TIME = 5;
+       private static final int PORT_WAIT_TIME = 5 * 1000 * 2;  //ms
        private static List<String> portLines = new ArrayList<String>();
        public static final int LOCAL_PORT = 8000;
 
@@ -167,7 +166,7 @@ public class CommunicatorUtils {
                        String targetPath) {
                HostResult ret = HostResult.SUCCESS;
                SyncResult result = push(device, source, targetPath);
-               if (null == result || RESULT_OK != result.getCode()) {
+               if (null == result || !result.isOk()) {
                        System.out.println("upload to" + targetPath + " is failed! "); //$NON-NLS-1$ //$NON-NLS-2$
                        if (null != result) {
                                ret = HostResult.ERR_UPLOAD_FILE_FAILED;
@@ -302,7 +301,7 @@ public class CommunicatorUtils {
                                }
                                count++;
                                System.out.print("wait for port..");
-                               Thread.sleep(1000);
+                               Thread.sleep(1);
                        } catch (InterruptedException e) {
                                e.printStackTrace();
                                break;
index 32fef5b..fe44b2a 100644 (file)
@@ -4,7 +4,6 @@ import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.DAEMONLOG_COUNT
 import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.DAEMONLOG_PREFIX;
 import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.DA_VERSION_OLD;
 import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.DA_VERSION_SWAP;
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
 import static org.tizen.sdblib.util.DeviceUtil.isOnline;
 
 import java.io.BufferedReader;
@@ -36,6 +35,7 @@ import org.tizen.sdblib.service.SyncResult;
 public class DACommunicator {
        public static int MSG_TYPE_CONFIG = 0;
        public static int MSG_TYPE_SWAP_INST = 1;
+       public static int READ_BUFFER_SIZE = 1024;
 
        private static BaseCommunicator communicator = null;
 
@@ -937,7 +937,7 @@ public class DACommunicator {
                final String to = PathManager.getLogPath() + File.separator
                                + DAEMONLOG_PREFIX + PathManager.getLogPostFix();//$NON-NLS-1$ 
                SyncResult res = CommunicatorUtils.pull(from, to);
-               if (null != res && RESULT_OK == res.getCode()) {
+               if (null != res && res.isOk()) {
                        System.out.println("daemon log copying success!!");//$NON-NLS-1$ 
                } else {
                        System.out.println("Failed to get " + from); //$NON-NLS-1$ 
index 533ff91..d2f22d4 100755 (executable)
@@ -25,8 +25,6 @@
  */
 package org.tizen.dynamicanalyzer.logparser;
 
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
-
 import java.io.File;
 import java.util.List;
 
@@ -39,7 +37,6 @@ import org.tizen.dynamicanalyzer.model.ImageInfo;
 import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
 import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.swap.logparser.LogPackage;
-import org.tizen.dynamicanalyzer.swap.model.DATime;
 import org.tizen.dynamicanalyzer.swap.model.data.ApiNameManager;
 import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage;
 import org.tizen.dynamicanalyzer.swap.model.probe2.LogData;
@@ -372,7 +369,7 @@ public class LogParser implements Runnable {
                        public void run() {
                                while (true && count < 5) {
                                        SyncResult res = CommunicatorUtils.pull(from, to);
-                                       if (null != res && RESULT_OK == res.getCode()) {
+                                       if (null != res && res.isOk()) {
                                                /* image resizing */
                                                String smallImagePath = AnalyzerManager.getProject()
                                                                .getSavePath()
index c239610..d9b0e97 100755 (executable)
@@ -8,7 +8,6 @@ import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_STOP_ACK;
 import static org.tizen.dynamicanalyzer.common.AnalyzerConstants.MSG_TARGET_INFO_ACK;
 import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE;
 import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE;
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -22,7 +21,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
-import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
 import org.tizen.dynamicanalyzer.common.AnalyzerShellCommands;
 import org.tizen.dynamicanalyzer.common.CommonConstants;
@@ -107,6 +105,7 @@ public class Communicator30 extends BaseCommunicator {
                        devices.removeAll(removeList);
                        removeList.clear();
                }
+               // port get failed popup
 
                // create control socket
                for (DeviceInfo devInfo : devices) {
@@ -118,6 +117,7 @@ public class Communicator30 extends BaseCommunicator {
                                result = createDataSocket(devInfo);
                                if (!result.isSuccess()) {
                                        System.out.println(result.toString());
+                                       // add control socket close
                                        removeList.add(devInfo);
                                }
                        }
@@ -149,11 +149,10 @@ public class Communicator30 extends BaseCommunicator {
                }
 
                // heart beat thread start
-
                // Thread heartBeat = new Thread(null, new HeartBeatThread(),
                // AnalyzerConstants.HEART_BEAT_THREAD);
                // heartBeat.start();
-
+               //
                return HostResult.SUCCESS;
        }
 
@@ -202,9 +201,11 @@ public class Communicator30 extends BaseCommunicator {
                }
 
                // TODO: app inst , replay info added!!
+//             byte[] rear = ByteUtils.getByte(appInfo.getByteValue(),
+//                             rt.getByteValue(), getUserSpaceInst().getByteValue(),
+//                             replayEvent);
                byte[] rear = ByteUtils.getByte(appInfo.getByteValue(),
-                               rt.getByteValue(), getUserSpaceInst().getByteValue(),
-                               replayEvent);
+                               rt.getByteValue(), 0,0);
                int length = rear.length;
 
                byte[] ret = ByteUtils.getByte(AnalyzerConstants.MSG_START_SWAP,
@@ -321,7 +322,7 @@ public class Communicator30 extends BaseCommunicator {
                        String name = selectedApp.getInfo(AppInfo.LABEL_INDEX);
                        binaryPath = AnalyzerPaths.TEMP_FOLDER_PATH + File.separator + name;
                        SyncResult res = CommunicatorUtils.pull(targetPath, binaryPath);
-                       if (null != res && RESULT_OK == res.getCode()) {
+                       if (null != res && res.isOk()) {
                                System.out.println("binary copy success!!");//$NON-NLS-1$ 
                        } else {
                                System.out.println("Failed to get " + targetPath); //$NON-NLS-1$ 
@@ -368,7 +369,7 @@ public class Communicator30 extends BaseCommunicator {
                if (!targetHashCode.equals(localHashCode)) {
                        SyncResult res = CommunicatorUtils.pull(targetPath,
                                        AnalyzerPaths.TEMP_FOLDER_PATH);
-                       if (null != res && RESULT_OK == res.getCode()) {
+                       if (null != res && res.isOk()) {
                                System.out.println("binary copy success!!");//$NON-NLS-1$ 
                        } else {
                                System.out.println("Failed to get " + targetPath + "  step 2"); //$NON-NLS-1$ 
@@ -463,8 +464,8 @@ public class Communicator30 extends BaseCommunicator {
                        System.out.println("wait for ack... [send message : " + message
                                        + " ]");
                        int readsize = -1;
-                       // while (readsize < 0) {
-                       byte[] cbuf = new byte[64];
+                       // read buffer size is sufficient??
+                       byte[] cbuf = new byte[DACommunicator.READ_BUFFER_SIZE * 2];
                        blocked = true;
                        readsize = controlSock.getInputStream().read(cbuf);
                        blocked = false;
index 0bdaed6..eb8563f 100755 (executable)
@@ -27,7 +27,6 @@ package org.tizen.dynamicanalyzer.swap.logparser;
 
 import static org.tizen.dynamicanalyzer.common.CommonConstants.INT_SIZE;
 import static org.tizen.dynamicanalyzer.common.CommonConstants.LONG_SIZE;
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
 
 import java.io.File;
 import java.io.IOException;
@@ -49,7 +48,6 @@ import org.tizen.dynamicanalyzer.communicator.DACommunicator;
 import org.tizen.dynamicanalyzer.handlers.ReplayTraceHandler;
 import org.tizen.dynamicanalyzer.handlers.StopHandler;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.services.RecordStateSourceProvider;
 import org.tizen.dynamicanalyzer.swap.model.ByteUtils;
 import org.tizen.dynamicanalyzer.swap.model.DATime;
 import org.tizen.dynamicanalyzer.swap.model.LogContainer;
@@ -219,7 +217,7 @@ public class MessageParser {
                        @Override
                        public void run() {
                                SyncResult res = CommunicatorUtils.pull(from, to);
-                               if (null != res && RESULT_OK == res.getCode()) {
+                               if (null != res && res.isOk()) {
                                        DACommunicator.removeCommand(from);
                                } else {
                                        System.out.println("Failed to get '" + from + "' file"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -242,29 +240,7 @@ public class MessageParser {
                DACommunicator.setRunning(false);
        }
 
-       public void testParsing(byte[] input) {
-               byte[] buf = input;
-               BasicDataMessage dataMessage = null;
-               if (null == dataMessage) {
-                       dataMessage = new BasicDataMessage();
-                       buf = dataMessage.makeData(buf);
-               }
-               // else {
-               // buf = dataMessage.addData(buf);
-               // }
-
-               while (dataMessage.isComplete()) {
-                       // dataMessage push to queue
-                       processMessage(dataMessage);
-                       dataMessage = new BasicDataMessage();
-                       buf = dataMessage.makeData(buf);
-               }
-
-               // System.arraycopy(empty, 0, buf, 0, empty.length);
-       }
-
        public void startMessageParsing(Socket dataSocket) {
-               // byte[] empty = new byte[1024];
                byte[] buf = new byte[1024 * 10];
                InputStream inputStream = null;
 
@@ -284,7 +260,7 @@ public class MessageParser {
                                if (readSize <= 0) {
                                        continue;
                                } else {
-                                       System.out.println("read size : " + readSize);
+//                                     System.out.println("read size : " + readSize);
                                        readBuf = new byte[readSize];
                                        System.arraycopy(buf, 0, readBuf, 0, readSize);
                                }
@@ -304,8 +280,6 @@ public class MessageParser {
                                while (null != dataMessage && dataMessage.isComplete()
                                                && DACommunicator.isRunning()) {
                                        // dataMessage push to queue
-                                       System.out.println("dataMessage seq "
-                                                       + dataMessage.getSeq());
                                        processMessage(dataMessage);
                                        dataMessage = null;
                                        if (readBuf.length > 0) {
@@ -367,8 +341,10 @@ public class MessageParser {
        }
 
        private void processMessage(BasicDataMessage data) {
+               data.printMessage();
                int messageId = data.getId();
                LogData log = null;
+
                switch (messageId) {
                case DataChannelConstants.MSG_PROCESS_INFO:
                        // setting process info
index b85e603..9c0aaad 100755 (executable)
@@ -25,8 +25,6 @@
  */
 package org.tizen.dynamicanalyzer.swap.logparser;
 
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
-
 import java.io.File;
 import java.util.List;
 
@@ -257,7 +255,7 @@ public class SWAPLogParser implements Runnable {
                        public void run() {
                                while (true && count < 5) {
                                        SyncResult res = CommunicatorUtils.pull(from, to);
-                                       if (null != res && RESULT_OK == res.getCode()) {
+                                       if (null != res && res.isOk()) {
                                                DACommunicator.removeCommand(from);
                                                /* image resizing */
                                                String smallImagePath = AnalyzerManager.getProject()
index e218ec7..d107514 100755 (executable)
@@ -5,8 +5,17 @@ import org.tizen.dynamicanalyzer.swap.model.SWAPModel;
 
 public class RunTimeConfiguration implements SWAPModel {
        private long features = 0;
+       private long preFeatures = 0;
        private int systemTraceInterval = 1000;
-       private int dataMessageInterval = 1000;
+       private int dataMessageInterval = 10;
+
+       public long getPreFeatures() {
+               return preFeatures;
+       }
+
+       public void setPreFeatures(long preFeatures) {
+               this.preFeatures = preFeatures;
+       }
 
        public long getFeatures() {
                return features;
@@ -34,7 +43,7 @@ public class RunTimeConfiguration implements SWAPModel {
 
        @Override
        public byte[] getByteValue() {
-               return ByteUtils.getByte(features, systemTraceInterval,
+               return ByteUtils.getByte(preFeatures, features, systemTraceInterval,
                                dataMessageInterval);
        }
 
index 5ffd9d3..ef72828 100644 (file)
@@ -57,16 +57,12 @@ public class BasicDataMessage {
                                reqSize = 0;
                        }
                        // parsing header
-//                     ByteUtils.printByteArray(headerBuffer);
+                       // ByteUtils.printByteArray(headerBuffer);
                        id = ByteUtils.toInt(headerBuffer);
-                       if (id < 0) {
-                               System.out.println("debug");
-                       }
                        seq = ByteUtils.toInt(headerBuffer, ID_SIZE);
                        long sec = ByteUtils.toInt(headerBuffer, ID_SIZE + SEQ_SIZE);
                        long nano = ByteUtils.toInt(headerBuffer, ID_SIZE + SEQ_SIZE
                                        + INT_SIZE);
-//                     System.out.println("time " + sec + "    nano " + nano);
 
                        long startSec = AnalyzerManager.getProject().getStartTime()
                                        .getSec();
@@ -84,10 +80,10 @@ public class BasicDataMessage {
                        System.arraycopy(emptyHeaderBuffer, 0, headerBuffer, 0, HEADER_SIZE);
                        // input - headerBuffer = buffer
                        payload = new byte[payloadSize];
-                       System.out.println("DEBUG -  id :" + String.format("%4x", id) + "   seq :" + seq
-                                       + "  time :" + time + "   payload size : " + payloadSize
-                                       + "   request size :" + reqSize + " input length :"
-                                       + input.length);
+//                     System.out.println("DEBUG -  id :" + String.format("%4x", id)
+//                                     + "   seq :" + seq + "  time :" + time
+//                                     + "   payload size : " + payloadSize + "   request size :"
+//                                     + reqSize + " input length :" + input.length);
                }
 
                reqSize = (0 == reqSize) ? payloadSize : reqSize;
@@ -226,6 +222,7 @@ public class BasicDataMessage {
                payloadSize = payload.length;
        }
 
+       // for lower version
        private static int mappingId(int oldId) {
                int newId = -1;
                switch (oldId) {
@@ -280,4 +277,11 @@ public class BasicDataMessage {
        public String getCallstack() {
                return callstackLog;
        }
+
+       public void printMessage() {
+               String strId = String.format("%4x", id);
+               System.out.println("Message [id : " + strId + "] [seq :" + seq
+                               + "] [ Time : " + time + " ms]");
+               ByteUtils.printByteArray(payload);
+       }
 }
index 6668514..76de58a 100644 (file)
@@ -448,19 +448,19 @@ public class DataFactory {
                int processCount = ByteUtils.toInt(payload, index);
                index += INT_SIZE;
 
-               // String processLoad = parseLoad(index, payload);
-               // index += (processCount * (INT_SIZE + FLOAT_SIZE));
-               //
-               // int diskReadSize = ByteUtils.toInt(payload, index);
-               // index += INT_SIZE;
-               //
-               // int diskWriteSize = ByteUtils.toInt(payload, index);
-               // index += INT_SIZE;
-               //
-               // int networkSendSize = ByteUtils.toInt(payload, index);
-               // index += INT_SIZE;
-               //
-               // int networkReceiveSize = ByteUtils.toInt(payload, index);
+               String processLoad = parseLoad(index, payload);
+               index += (processCount * (INT_SIZE + FLOAT_SIZE));
+
+               int diskReadSize = ByteUtils.toInt(payload, index);
+               index += INT_SIZE;
+
+               int diskWriteSize = ByteUtils.toInt(payload, index);
+               index += INT_SIZE;
+
+               int networkSendSize = ByteUtils.toInt(payload, index);
+               index += INT_SIZE;
+
+               int networkReceiveSize = ByteUtils.toInt(payload, index);
 
                data.setEnergy(energy);
                data.setWifi(wifi);
@@ -490,11 +490,11 @@ public class DataFactory {
                data.setThreadCount(threadCount);
                data.setThreadLoad(threadLoad);
                data.setProcessCount(processCount);
-               // data.setProcessLoad(processLoad);
-               // data.setDiskReadSize(diskReadSize);
-               // data.setDiskWriteSize(diskWriteSize);
-               // data.setNetworkSendSize(networkSendSize);
-               // data.setNetworkReceiveSize(networkReceiveSize);
+               data.setProcessLoad(processLoad);
+               data.setDiskReadSize(diskReadSize);
+               data.setDiskWriteSize(diskWriteSize);
+               data.setNetworkSendSize(networkSendSize);
+               data.setNetworkReceiveSize(networkReceiveSize);
        }
 
        private static void createProfileData(LogData log, byte[] payload) {
index 9b606a5..28b6e9e 100644 (file)
@@ -1,8 +1,6 @@
 package org.tizen.dynamicanalyzer.swap.model.probe2;
 
-import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.communicator.DACommunicator;
-import org.tizen.dynamicanalyzer.swap.model.DATime;
 import org.tizen.dynamicanalyzer.swap.model.data.BasicDataMessage;
 
 public class LogData {
index 1cb0f5d..7cc5d7f 100644 (file)
@@ -89,7 +89,11 @@ public class ConfigurationDialog {
 
        private void doApply() {
                ConfigurationDialogValues.getInstance().applySettingValueToConfigFile();
-               DACommunicator.sendRuntimeMessage(DACommunicator.MSG_TYPE_CONFIG, null);
+
+               if (DACommunicator.isRunning()) {
+                       DACommunicator.sendRuntimeMessage(DACommunicator.MSG_TYPE_CONFIG,
+                                       null);
+               }
        }
 
        private void doBack() {
index 03faa03..c4a4e0c 100755 (executable)
@@ -26,8 +26,6 @@
 
 package org.tizen.dynamicanalyzer.utils;
 
-import static org.tizen.sdblib.service.SyncServiceConstants.RESULT_OK;
-
 import java.io.BufferedReader;
 import java.io.Closeable;
 import java.io.File;
@@ -85,7 +83,8 @@ import org.tizen.sdblib.service.SyncResult;
 
 public class AnalyzerUtil {
        private static IWorkbenchWindow window = null;
-//     private static String recordState = RecordStateSourceProvider.RECORD_READY;
+       // private static String recordState =
+       // RecordStateSourceProvider.RECORD_READY;
        private static final int ENLARGED_LENGTH = 12;
 
        // FIXME start
@@ -251,9 +250,9 @@ public class AnalyzerUtil {
                return CommonConstants.EMPTY;
        }
 
-//     public static String getRecordState() {
-//             return recordState;
-//     }
+       // public static String getRecordState() {
+       // return recordState;
+       // }
 
        public static ViewPart getViewPart(String id) {
                IWorkbenchPage page = getWorkbenchWindow().getActivePage();
@@ -333,9 +332,9 @@ public class AnalyzerUtil {
                });
        }
 
-//     public static void setRecordState(final String state) {
-//             recordState = state;
-//     }
+       // public static void setRecordState(final String state) {
+       // recordState = state;
+       // }
 
        public static int getTableItemHeight(Grid table) {
                GC gc = new GC(table);
@@ -964,7 +963,7 @@ public class AnalyzerUtil {
                                + AnalyzerConstants.API_NAME_FILE_NAME;
                SyncResult res = CommunicatorUtils.pull(device,
                                AnalyzerPaths.DA_API_MAP_PATH, apiFilePath);
-               if (null != res && RESULT_OK == res.getCode()) {
+               if (null != res && res.isOk()) {
                        System.out.println("api map copying success!!");//$NON-NLS-1$ 
                } else {
                        System.out.println("Failed to get " + apiFilePath); //$NON-NLS-1$