[Title]extension Point added
authorjy.exe.lee <jy.exe.lee@samsung.com>
Mon, 31 Oct 2011 10:39:38 +0000 (19:39 +0900)
committerjy.exe.lee <jy.exe.lee@samsung.com>
Mon, 31 Oct 2011 10:39:38 +0000 (19:39 +0900)
[Type]feature
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

com.samsung.dynamicanalyzer/plugin.xml
com.samsung.dynamicanalyzer/schema/com.samsung.dynamicanalyzer.exsd
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/AnalyzerManager.java [new file with mode: 0644]
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/LogSpliter.java [new file with mode: 0644]
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/constants/AnalyzerConstants.java
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/extensionPoints/IUpdateLog.java [new file with mode: 0644]
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/handlers/OpenTraceHandler.java
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/model/LogPackage.java [new file with mode: 0644]
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/model/Logs.java [new file with mode: 0644]
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/utils/SDBManager.java
com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalzyer/testCodes/LogParsingTest.java [new file with mode: 0644]

index 5fd2c33..97eb4c6 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <?eclipse version="3.4"?>\r
 <plugin>\r
+   <extension-point id="updateLog" name="%UpdateLog" schema="schema/com.samsung.dynamicanalyzer.exsd"/>\r
    <extension\r
          point="org.eclipse.ui.commands">\r
       <category\r
             name="%NtimeAnalysis"\r
             restorable="true">\r
       </view>\r
+   </extension>\r
+   <extension\r
+         point="com.samsung.dynamicanalyzer.updateLog">\r
+      <updateLog\r
+            class="com.samsung.dynamicanalzyer.testCodes.LogParsingTest">\r
+      </updateLog>\r
    </extension>
 </plugin>\r
index 4bcf22b..275e9ab 100644 (file)
-<?xml version='1.0' encoding='UTF-8'?>\r
-<!-- Schema file written by PDE -->\r
-<schema targetNamespace="com.samsung.dynamicanalyzer" xmlns="http://www.w3.org/2001/XMLSchema">\r
-<annotation>\r
-      <appinfo>\r
-         <meta.schema plugin="com.samsung.dynamicanalyzer" id="com.samsung.dynamicanalyzer" name="com.samsung.dynamicanalyzer"/>\r
-      </appinfo>\r
-      <documentation>\r
-         [Enter description of this extension point.]\r
-      </documentation>\r
-   </annotation>\r
-\r
-   <element name="extension">\r
-      <annotation>\r
-         <appinfo>\r
-            <meta.element />\r
-         </appinfo>\r
-      </annotation>\r
-      <complexType>\r
-         <choice>\r
-         </choice>\r
-         <attribute name="point" type="string" use="required">\r
-            <annotation>\r
-               <documentation>\r
-                  \r
-               </documentation>\r
-            </annotation>\r
-         </attribute>\r
-         <attribute name="id" type="string">\r
-            <annotation>\r
-               <documentation>\r
-                  \r
-               </documentation>\r
-            </annotation>\r
-         </attribute>\r
-         <attribute name="name" type="string">\r
-            <annotation>\r
-               <documentation>\r
-                  \r
-               </documentation>\r
-               <appinfo>\r
-                  <meta.attribute translatable="true"/>\r
-               </appinfo>\r
-            </annotation>\r
-         </attribute>\r
-      </complexType>\r
-   </element>\r
-\r
-   <annotation>\r
-      <appinfo>\r
-         <meta.section type="since"/>\r
-      </appinfo>\r
-      <documentation>\r
-         [Enter the first release in which this extension point appears.]\r
-      </documentation>\r
-   </annotation>\r
-\r
-   <annotation>\r
-      <appinfo>\r
-         <meta.section type="examples"/>\r
-      </appinfo>\r
-      <documentation>\r
-         [Enter extension point usage example here.]\r
-      </documentation>\r
-   </annotation>\r
-\r
-   <annotation>\r
-      <appinfo>\r
-         <meta.section type="apiinfo"/>\r
-      </appinfo>\r
-      <documentation>\r
-         [Enter API information here.]\r
-      </documentation>\r
-   </annotation>\r
-\r
-   <annotation>\r
-      <appinfo>\r
-         <meta.section type="implementation"/>\r
-      </appinfo>\r
-      <documentation>\r
-         [Enter information about supplied implementation of this extension point.]\r
-      </documentation>\r
-   </annotation>\r
-\r
-\r
-</schema>\r
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.samsung.dynamicanalyzer" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="com.samsung.dynamicanalyzer" id="com.samsung.dynamicanalyzer" name="com.samsung.dynamicanalyzer"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <choice>
+            <element ref="updateLog"/>
+         </choice>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="updateLog">
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn=":com.samsung.dynamicanalyzer.extensionPoints.IUpdateLog"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/AnalyzerManager.java b/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/AnalyzerManager.java
new file mode 100644 (file)
index 0000000..074dcc2
--- /dev/null
@@ -0,0 +1,29 @@
+package com.samsung.dynamicanalyzer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AnalyzerManager {
+       private static List<List<String>> logQueue = null;
+       
+       public static List<String> getFirst()
+       {
+               if (null == logQueue)
+               {
+                       logQueue = new ArrayList<List<String>>();
+                       return null;
+               }
+               List<String> output = logQueue.get(0);
+               logQueue.remove(0);
+               return output;
+       }
+
+       public static void putLog(List<String> input)
+       {
+               if (null == logQueue)
+               {
+                       logQueue = new ArrayList<List<String>>();
+               }
+               logQueue.add(input);
+       }
+}
diff --git a/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/LogSpliter.java b/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/LogSpliter.java
new file mode 100644 (file)
index 0000000..1e46369
--- /dev/null
@@ -0,0 +1,79 @@
+package com.samsung.dynamicanalyzer;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+
+import com.samsung.dynamicanalyzer.constants.AnalyzerConstants;
+import com.samsung.dynamicanalyzer.extensionPoints.IUpdateLog;
+import com.samsung.dynamicanalyzer.model.LogPackage;
+
+public class LogSpliter {
+
+       public static void logSlicing(List<String> logLumb) {
+               String[] slicedLog;
+
+               int size = logLumb.size();
+               String logId = null;
+               LogPackage logPack = new LogPackage();
+
+               for (int i = 0; i < size; i++) {
+                       slicedLog = logLumb.get(i).split(
+                                       AnalyzerConstants.DATA_PARSING_TOKEN);
+                       logId = slicedLog[0];
+                       pushLog(logId, slicedLog, logPack);
+                       insertLog(logId, slicedLog);
+                       if (!AnalyzerConstants.ZERO.equals(slicedLog[6])) {
+                               pushLog(AnalyzerConstants.ZERO, slicedLog, logPack);
+                               insertLog(logId, slicedLog);
+                       }
+               }
+
+               // extension point
+               IConfigurationElement[] config = Platform.getExtensionRegistry()
+                               .getConfigurationElementsFor(IUpdateLog.ID);
+
+               final LogPackage inputPack = logPack;
+
+               try {
+                       for (IConfigurationElement element : config) {
+                               final Object object = element
+                                               .createExecutableExtension(AnalyzerConstants.CLASS);
+                               if (object instanceof IUpdateLog) {
+                                       ISafeRunnable runnable = new ISafeRunnable() {
+                                               @Override
+                                               public void handleException(Throwable exception) {
+                                               }
+
+                                               @Override
+                                               public void run() throws Exception {
+                                                       if (!inputPack.isEmpty()) {
+                                                               ((IUpdateLog) object).postUpdateLog(inputPack);
+                                                       }
+                                               }
+                                       };
+                                       SafeRunner.run(runnable);
+                               }
+                       }
+               } catch (CoreException ex) {
+                       ex.printStackTrace();
+               }
+       }
+
+       private static void pushLog(String logId, String[] slicedLog,
+                       LogPackage logPack) {
+               int id = Integer.parseInt(logId);
+               logPack.setLogs(id, slicedLog);
+       }
+
+       private static void insertLog(String logId, String[] slicedLog) {
+               // TODO:
+               // sql insert query implement
+               // thread!!
+       }
+
+}
index e023008..b738c22 100644 (file)
@@ -24,6 +24,9 @@ public class AnalyzerConstants {
        public static final String TILDE = "~"; //$NON-NLS-1$\r
        public static final String ELLIPSIS = "..."; //$NON-NLS-1$\r
 \r
+       public static final String CLASS = "class"; //$NON-NLS-1$\r
+       public static final String ZERO = "0"; //$NON-NLS-1$\r
+       public static final String DATA_PARSING_TOKEN = "`,"; //$NON-NLS-1$\r
        private AnalyzerConstants() {\r
        }\r
 \r
diff --git a/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/extensionPoints/IUpdateLog.java b/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/extensionPoints/IUpdateLog.java
new file mode 100644 (file)
index 0000000..63c22d8
--- /dev/null
@@ -0,0 +1,10 @@
+package com.samsung.dynamicanalyzer.extensionPoints;
+
+import com.samsung.dynamicanalyzer.model.LogPackage;
+
+public interface IUpdateLog {
+
+       public static final String ID = "com.samsung.dynamicanalyzer.updateLog"; //$NON-NLS-1$
+       
+       void postUpdateLog(LogPackage logPack);
+}
index 4914647..ea3c9cc 100644 (file)
@@ -1,13 +1,26 @@
 package com.samsung.dynamicanalyzer.handlers;\r
 \r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
 \r
+import com.samsung.dynamicanalyzer.LogSpliter;\r
+\r
 public class OpenTraceHandler extends AbstractHandler {\r
 \r
        @Override\r
        public Object execute(ExecutionEvent event) throws ExecutionException {\r
+               List<String> input = new ArrayList<String>();\r
+               input.add("1`,2000`,1`,alloc`,test`,success`,0`,430303`,343433`,10`,3`,2323232");\r
+               input.add("1`,2000`,1`,alloc`,test`,success`,1`,430303`,343433`,10`,3`,2323232");\r
+               input.add("1`,2000`,1`,alloc`,test`,success`,2`,430303`,343433`,10`,3`,2323232");\r
+               input.add("1`,2000`,1`,alloc`,test`,success`,3`,430303`,343433`,10`,3`,2323232");\r
+               input.add("1`,2000`,1`,alloc`,test`,success`,4`,430303`,343433`,10`,3`,2323232");\r
+               input.add("1`,2000`,1`,alloc`,test`,success`,0`,430303`,343433`,10`,3`,2323232");\r
+               LogSpliter.logSlicing(input);\r
                return null;\r
        }\r
 \r
diff --git a/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/model/LogPackage.java b/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/model/LogPackage.java
new file mode 100644 (file)
index 0000000..57e3970
--- /dev/null
@@ -0,0 +1,45 @@
+package com.samsung.dynamicanalyzer.model;
+
+import java.util.HashMap;
+
+public class LogPackage {
+       private HashMap<Integer, Logs> logMap;
+
+       public LogPackage() {
+               logMap = new HashMap<Integer, Logs>();
+       }
+
+       public boolean isEmpty()
+       {
+               if (null == logMap)
+               {
+                       logMap = new HashMap<Integer, Logs>();
+               }
+
+               return logMap.isEmpty();
+       }
+
+       public void setLogs(int id, String[] input) {
+               if (null == logMap) {
+                       logMap = new HashMap<Integer, Logs>();
+               }
+
+               Logs logs = logMap.get(id);
+               if (null == logs)
+               {
+                       logs = new Logs(id);
+                       logMap.put(id, logs);
+               }
+               logs.getLogs().add(input);
+       }
+
+       public Logs getLogs(int id)
+       {
+               if (null == logMap) {
+                       logMap = new HashMap<Integer, Logs>();
+                       return null;
+               }
+
+               return logMap.get(id);
+       }
+}
diff --git a/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/model/Logs.java b/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalyzer/model/Logs.java
new file mode 100644 (file)
index 0000000..0f67479
--- /dev/null
@@ -0,0 +1,25 @@
+package com.samsung.dynamicanalyzer.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Logs {
+       private List<String[]> logs;
+       int logCenterId;
+
+       public Logs(int id) {
+               logs = new ArrayList<String[]>();
+               logCenterId = id;
+       }
+
+       public int getId() {
+               return logCenterId;
+       }
+
+       public List<String[]> getLogs() {
+               if (null == logs) {
+                       logs = new ArrayList<String[]>();
+               }
+               return logs;
+       }
+}
index 8a0596c..c25c1e0 100644 (file)
@@ -13,6 +13,8 @@ import java.util.TimerTask;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
+import com.samsung.dynamicanalyzer.AnalyzerManager;
+
 class RecieveThread implements Runnable {
        class AddBufferThread extends TimerTask {
 
@@ -32,9 +34,8 @@ class RecieveThread implements Runnable {
                        return;
                }
                //TODO remove 2 comment
-               //LogParser.getLogList().add(buffer);
+               AnalyzerManager.putLog(buffer);
                buffer = new ArrayList<String>();
-               //LogParser.startLogParsingThread();
                lock.unlock();
 
        }
@@ -58,17 +59,19 @@ class RecieveThread implements Runnable {
                        String message = null;
                        String[] msgs = null;
                        while (null != (message = br.readLine())) {
-                               // System.out.println("client recieve : " + cnt + " : " +
-                               // message);
+                                System.out.println("client recieve : " + cnt + " : " + message);
 
                                msgs = message.split("|", 4);
 
                                // //////// handle the message
+                               // 5 : log
                                if (msgs[1].charAt(0) == '5') {
                                        buffer.add(msgs[3]);
                                        buffer.add(br.readLine());
+                                       // 6: image
                                } else if (msgs[1].charAt(0) == '6') {
 
+                                       // 7: terminate
                                } else if (msgs[1].charAt(0) == '7') {
                                        SDBManager.getSock().close();
                                        br.close();
@@ -82,7 +85,7 @@ class RecieveThread implements Runnable {
 
                                // //////// Add buffer to list
                                if (cnt == 100) {
-                                       //addBufferToList();
+                                       addBufferToList();
                                        cnt = 0;
                                } else {
                                        cnt++;
diff --git a/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalzyer/testCodes/LogParsingTest.java b/com.samsung.dynamicanalyzer/src/com/samsung/dynamicanalzyer/testCodes/LogParsingTest.java
new file mode 100644 (file)
index 0000000..44d6342
--- /dev/null
@@ -0,0 +1,47 @@
+package com.samsung.dynamicanalzyer.testCodes;
+
+import com.samsung.dynamicanalyzer.extensionPoints.IUpdateLog;
+import com.samsung.dynamicanalyzer.model.LogPackage;
+import com.samsung.dynamicanalyzer.model.Logs;
+
+public class LogParsingTest implements IUpdateLog {
+
+       @Override
+       public void postUpdateLog(LogPackage logPack) {
+               // TODO Auto-generated method stub
+               Logs log1 = logPack.getLogs(1);
+               
+
+               int size = log1.getLogs().size();
+               int size2 = log1.getLogs().get(0).length;
+               StringBuffer sb = new StringBuffer();
+               for (int i = 0; i < size; i++)
+               {
+                       String[] str =  log1.getLogs().get(i);
+                       for (int j = 0; j < size2; j++)
+                       {
+                               sb.append(" " + str[j]);
+                       }
+                       System.out.println(sb.toString());
+                       sb.delete(0, sb.length());
+               }
+               
+               System.out.println();
+               System.out.println();
+               
+               Logs log2 = logPack.getLogs(0);
+               size = log2.getLogs().size();
+               size2 = log2.getLogs().get(0).length;
+               for (int i = 0; i < size; i++)
+               {
+                       String[] str =  log2.getLogs().get(i);
+                       for (int j = 0; j < size2; j++)
+                       {
+                               sb.append(" " + str[j]);
+                       }
+                       System.out.println(sb.toString());
+                       sb.delete(0, sb.length());
+               }
+       }
+
+}