<?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
-<?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>
--- /dev/null
+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);
+ }
+}
--- /dev/null
+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!!
+ }
+
+}
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
--- /dev/null
+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);
+}
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
--- /dev/null
+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);
+ }
+}
--- /dev/null
+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;
+ }
+}
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 {
return;
}
//TODO remove 2 comment
- //LogParser.getLogList().add(buffer);
+ AnalyzerManager.putLog(buffer);
buffer = new ArrayList<String>();
- //LogParser.startLogParsingThread();
lock.unlock();
}
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();
// //////// Add buffer to list
if (cnt == 100) {
- //addBufferToList();
+ addBufferToList();
cnt = 0;
} else {
cnt++;
--- /dev/null
+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());
+ }
+ }
+
+}