Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 256:547a88631e55 Implementation_of_communication
merge
author | tatsuki |
---|---|
date | Fri, 18 Nov 2016 22:17:48 +0900 |
parents | fdd7ed360a48 (current diff) 28d3a177f540 (diff) |
children | 69fd63676e8b |
files | build.gradle src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataReadBenchmark.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/xml/reader/xmlReader.java |
diffstat | 6 files changed, 145 insertions(+), 136 deletions(-) [+] |
line wrap: on
line diff
--- a/build.gradle Fri Nov 18 22:02:48 2016 +0900 +++ b/build.gradle Fri Nov 18 22:17:48 2016 +0900 @@ -10,6 +10,7 @@ mavenCentral() maven { url "http://eaio.com/maven2" } maven { url "http://repo.maven.apache.org/maven2" } + maven { url "http://www.cr.ie.u-ryukyu.ac.jp/hg/maven/raw-file/e6b119647469/"} } dependencies { @@ -18,18 +19,19 @@ compile "org.apache.maven.surefire:surefire-junit4:2.13" compile "com.google.guava:guava:12.0" compile fileTree(dir: 'lib', include: '*.jar') - compile group: 'junit', name: 'junit', version: '4.11' - compile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.2.1.v20140609' + compile "junit:junit:4.7" + compile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.1.1.v20140108' compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.2.1.v20140609' compile group: 'org.hectorclient', name: 'hector-core', version:'1.1-2' compile group: 'com.github.stephenc.eaio-uuid', name: 'uuid', version:'3.3.0' - compile group: 'org.apache.cassandra', name: 'cassandra-all', version: '3.9' - + compile(group: 'org.apache.cassandra', name: 'cassandra-all', version:'1.2.1') { + exclude(module: 'slf4j-log4j12') + exclude(module: 'log4j') + } } -ext { - mavenRepository = System.getenv()['HOME']+'/Documents/workspace/maven' -} + + jar { manifest { @@ -39,10 +41,3 @@ archiveName = 'jungle-core.jar' } -uploadArchives { - repositories { - mavenDeployer { - repository(url: uri(mavenRepository)) - } - } -}
--- a/memo.txt Fri Nov 18 22:02:48 2016 +0900 +++ b/memo.txt Fri Nov 18 22:17:48 2016 +0900 @@ -1,3 +1,17 @@ +Thu Nov 17 18:36:13 JST 2016 + + 差分List + JungleTreeをRedBlackTreeにする + それ用のAPIを設計する + Logの書き出しの高速化 + Buffering + Mergeの実装 + APIの設計 + 共通のRootからの複数の変更履歴を一つにまとめる + JungleNodeに特定Objectをもたせれるようにする + + 金川 + Fri Jul 18 19:59:20 JST 2014 servletから最初にBoardNameをKeyにTreeを持ってくる @@ -70,4 +84,4 @@ 2012/06/28 ・SimpleJungle 実装を完成させた。テストコードはまだ書いていない - ・SimpleEditor の部分がまだだった。明日完成させよう \ No newline at end of file + ・SimpleEditor の部分がまだだった。明日完成させよう
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataReadBenchMark.java Fri Nov 18 22:17:48 2016 +0900 @@ -0,0 +1,87 @@ +package jp.ac.u_ryukyu.ie.cr.benchMark.persistent; + +import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeList; +import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeListReader; +import jp.ac.u_ryukyu.ie.cr.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations.NetworkNodePath; +import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; +import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle; +import jp.ac.u_ryukyu.ie.cr.jungleNetwork.transaction.JungleUpdater; +import org.junit.Assert; + +import java.io.*; +import java.nio.ByteBuffer; + +public class DataReadBenchMark { + + static ByteBuffer value = ByteBuffer.wrap("value".getBytes()); + static String key = "key"; + static int pos = 0; + + public static void main(String[] args) throws IOException { + + PersistentJournal journal1 = new PersistentJournal(new File("./log/commit.log")); + Jungle jungle = new PersistentJungle(journal1, "uuid", new DefaultTreeEditor(new DefaultTraverser())); + Jungle jungle2 = new PersistentJungle(journal1, "uuid3", new DefaultTreeEditor(new DefaultTraverser())); + Long t1; + Long t2; + PrintWriter readTimeWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File("./time/readTime")))); + PrintWriter writeTimeWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File("./time/writeTime")))); + for (int i = 1 ; i <= 20 ; i++) { + jungle.createNewTree("hoge" + i); + JungleTree tree1 = jungle.getTreeByName("hoge" + i); + JungleTreeEditor editor; + NetworkNodePath path = new NetworkNodePath(); + t1 = System.currentTimeMillis(); + for (int j = 0; j < 100 * i; j++) { + editor = tree1.getTreeEditor(); + Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, pos); + NodePath childPath = path.add(pos); + Assert.assertFalse(either.isA()); + editor = either.b(); + either = editor.putAttribute(childPath, key, value); + JungleTreeEditor editor2 = either.b(); + either = editor2.success(); + Assert.assertFalse(either.isA()); + } + t2 = System.currentTimeMillis(); + + writeTimeWriter.println((100 * i) + " " + (t2 - t1)); + System.out.println("write time = " + (t2 - t1)); + + PersistentJournal journal2 = new PersistentJournal(); + journal2.setInputFile(new File("./log/" + journal1.getLogName())); + journal2.setOutputFile(new File("./log/" + journal1.getLogName())); + ChangeListReader reader = journal2.getReader(); + + t1 = System.currentTimeMillis(); + for (ChangeList chList : reader) { + String treeName = chList.getTreeName(); + JungleTree tree2 = jungle2.getTreeByName(treeName); + if (tree2 == null) { + tree2 = jungle2.createNewTree(treeName); + } + JungleTreeEditor editor2 = tree2.getTreeEditor(); + Either<Error, JungleTreeEditor> either2 = JungleUpdater.edit(editor2, chList); + Assert.assertFalse(either2.isA()); + editor2 = either2.b(); + editor2.success(); + } + + t2 = System.currentTimeMillis(); + readTimeWriter.println((100 * i) + " " + (t2 - t1)); + System.out.println("read time = " + (t2 - t1)); + + } + writeTimeWriter.close(); + readTimeWriter.close(); + journal1.close(); + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataReadBenchmark.java Fri Nov 18 22:02:48 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.benchMark.persistent; - -import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; -import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; -import jp.ac.u_ryukyu.ie.cr.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeList; -import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeListReader; -import jp.ac.u_ryukyu.ie.cr.jungle.store.NodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations.NetworkNodePath; -import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; -import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle; -import jp.ac.u_ryukyu.ie.cr.jungleNetwork.transaction.JungleUpdater; -import org.junit.Assert; - -import java.io.*; -import java.nio.ByteBuffer; - -public class DataReadBenchMark { - - static ByteBuffer value = ByteBuffer.wrap("value".getBytes()); - static String key = "key"; - static int pos = 0; - - public static void main(String[] args) throws IOException { - - PersistentJournal journal1 = new PersistentJournal(new File("./log/commit.log")); - Jungle jungle = new PersistentJungle(journal1, "uuid", new DefaultTreeEditor(new DefaultTraverser())); - Jungle jungle2 = new PersistentJungle(journal1, "uuid3", new DefaultTreeEditor(new DefaultTraverser())); - Long t1; - Long t2; - PrintWriter readTimeWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File("./time/readTime")))); - PrintWriter writeTimeWriter = new PrintWriter(new BufferedWriter(new FileWriter(new File("./time/writeTime")))); - for (int i = 1 ; i <= 20 ; i++) { - jungle.createNewTree("hoge" + i); - JungleTree tree1 = jungle.getTreeByName("hoge" + i); - JungleTreeEditor editor; - NetworkNodePath path = new NetworkNodePath(); - t1 = System.currentTimeMillis(); - for (int j = 0; j < 100 * i; j++) { - editor = tree1.getTreeEditor(); - Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, pos); - NodePath childPath = path.add(pos); - Assert.assertFalse(either.isA()); - editor = either.b(); - either = editor.putAttribute(childPath, key, value); - JungleTreeEditor editor2 = either.b(); - either = editor2.success(); - Assert.assertFalse(either.isA()); - } - t2 = System.currentTimeMillis(); - - writeTimeWriter.println((100 * i) + " " + (t2 - t1)); - System.out.println("write time = " + (t2 - t1)); - - PersistentJournal journal2 = new PersistentJournal(); - journal2.setInputFile(new File("./log/" + journal1.getLogName())); - journal2.setOutputFile(new File("./log/" + journal1.getLogName())); - ChangeListReader reader = journal2.getReader(); - - t1 = System.currentTimeMillis(); - for (ChangeList chList : reader) { - String treeName = chList.getTreeName(); - JungleTree tree2 = jungle2.getTreeByName(treeName); - if (tree2 == null) { - tree2 = jungle2.createNewTree(treeName); - } - JungleTreeEditor editor2 = tree2.getTreeEditor(); - Either<Error, JungleTreeEditor> either2 = JungleUpdater.edit(editor2, chList); - Assert.assertFalse(either2.isA()); - editor2 = either2.b(); - editor2.success(); - } - - t2 = System.currentTimeMillis(); - readTimeWriter.println((100 * i) + " " + (t2 - t1)); - System.out.println("read time = " + (t2 - t1)); - - } - writeTimeWriter.close(); - readTimeWriter.close(); - journal1.close(); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/xml/reader/XmlReader.java Fri Nov 18 22:17:48 2016 +0900 @@ -0,0 +1,34 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.xml.reader; + +import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.FileInputStream; + + +public class XmlReader { + public static void main(String args[]) { + String xmlPath = args[0]; + Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); + JungleTree tree = jungle.createNewTree("XMLTEST"); + new XmlReader().start(xmlPath,tree); + } + + public JungleTree start(String xmlPath, JungleTree tree) { + try { + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + SAXParser saxParser = saxParserFactory.newSAXParser(); + ReadXmlHandler readXmlHandler = new ReadXmlHandler(tree); + saxParser.parse(new FileInputStream(xmlPath), readXmlHandler); + return readXmlHandler.getTree(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } +} \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/xml/reader/xmlReader.java Fri Nov 18 22:02:48 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.xml.reader; - -import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; -import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; -import jp.ac.u_ryukyu.ie.cr.jungle.JungleTree; -import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import java.io.FileInputStream; - - -public class XmlReader { - public static void main(String args[]) { - String xmlPath = args[0]; - Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); - JungleTree tree = jungle.createNewTree("XMLTEST"); - new XmlReader().start(xmlPath,tree); - } - - public JungleTree start(String xmlPath, JungleTree tree) { - try { - SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); - SAXParser saxParser = saxParserFactory.newSAXParser(); - ReadXmlHandler readXmlHandler = new ReadXmlHandler(tree); - saxParser.parse(new FileInputStream(xmlPath), readXmlHandler); - return readXmlHandler.getTree(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} \ No newline at end of file