changeset 151:acf127ec8d8c

マージ fizzbuzz
author musou_aka
date Tue, 08 Jan 2019 19:03:33 +0900
parents 37b28ffbab2f (current diff) a5cd12f6a942 (diff)
children 57f4ef5e3d08
files
diffstat 137 files changed, 251 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
Binary file .DS_Store has changed
Binary file out/production/classes/META-INF/cr.ie.u_ryukyu.ac.jp.Christie.main.kotlin_module has changed
Binary file out/production/classes/christie/annotation/Peek.class has changed
Binary file out/production/classes/christie/annotation/PeekFrom.class has changed
Binary file out/production/classes/christie/annotation/Take.class has changed
Binary file out/production/classes/christie/annotation/TakeFrom.class has changed
Binary file out/production/classes/christie/blockchain/Block.class has changed
Binary file out/production/classes/christie/blockchain/BlockChain.class has changed
Binary file out/production/classes/christie/blockchain/BlockHeader.class has changed
Binary file out/production/classes/christie/blockchain/ECKey.class has changed
Binary file out/production/classes/christie/blockchain/HashUtil.class has changed
Binary file out/production/classes/christie/blockchain/Miner.class has changed
Binary file out/production/classes/christie/blockchain/Transaction.class has changed
Binary file out/production/classes/christie/codegear/CodeGear.class has changed
Binary file out/production/classes/christie/codegear/CodeGearExecutor.class has changed
Binary file out/production/classes/christie/codegear/CodeGearManager.class has changed
Binary file out/production/classes/christie/codegear/InputDataGear.class has changed
Binary file out/production/classes/christie/codegear/StartCodeGear.class has changed
Binary file out/production/classes/christie/daemon/AcceptThread.class has changed
Binary file out/production/classes/christie/daemon/ChristieDaemon.class has changed
Binary file out/production/classes/christie/daemon/Config.class has changed
Binary file out/production/classes/christie/daemon/Connection.class has changed
Binary file out/production/classes/christie/daemon/IncomingTcpConnection$1.class has changed
Binary file out/production/classes/christie/daemon/IncomingTcpConnection.class has changed
Binary file out/production/classes/christie/daemon/OutboundTcpConnection$1.class has changed
Binary file out/production/classes/christie/daemon/OutboundTcpConnection.class has changed
Binary file out/production/classes/christie/datagear/DataGearManager.class has changed
Binary file out/production/classes/christie/datagear/DataGears.class has changed
Binary file out/production/classes/christie/datagear/LocalDataGearManager$1.class has changed
Binary file out/production/classes/christie/datagear/LocalDataGearManager.class has changed
Binary file out/production/classes/christie/datagear/RemoteDataGearManager$1.class has changed
Binary file out/production/classes/christie/datagear/RemoteDataGearManager$2.class has changed
Binary file out/production/classes/christie/datagear/RemoteDataGearManager.class has changed
Binary file out/production/classes/christie/datagear/RemoteMessage.class has changed
Binary file out/production/classes/christie/datagear/WaitList.class has changed
Binary file out/production/classes/christie/datagear/WrapperClass.class has changed
Binary file out/production/classes/christie/datagear/command/CloseCommand.class has changed
Binary file out/production/classes/christie/datagear/command/Command.class has changed
Binary file out/production/classes/christie/datagear/command/CommandType.class has changed
Binary file out/production/classes/christie/datagear/command/ConvertedCommand.class has changed
Binary file out/production/classes/christie/datagear/command/FinishCommand.class has changed
Binary file out/production/classes/christie/datagear/command/PeekCommand.class has changed
Binary file out/production/classes/christie/datagear/command/PutCommand.class has changed
Binary file out/production/classes/christie/datagear/command/RemotePeekCommand.class has changed
Binary file out/production/classes/christie/datagear/command/RemoteTakeCommand.class has changed
Binary file out/production/classes/christie/datagear/command/ReplyCommand.class has changed
Binary file out/production/classes/christie/datagear/command/TakeCommand.class has changed
Binary file out/production/classes/christie/datagear/dg/DataGear.class has changed
Binary file out/production/classes/christie/datagear/dg/MessagePackDataGear.class has changed
Binary file out/production/classes/christie/test/Paxos/AcceptCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/AcceptorCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/PromiseCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/Proposal.class has changed
Binary file out/production/classes/christie/test/Paxos/ProposerCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/ReceivePromiseCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/SendAcceptRequestCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/SendPrepareRequestCodeGear.class has changed
Binary file out/production/classes/christie/test/Paxos/StartPaxos.class has changed
Binary file out/production/classes/christie/test/Remote/CreateRemotePutTest.class has changed
Binary file out/production/classes/christie/test/Remote/RemotePutTest.class has changed
Binary file out/production/classes/christie/test/Remote/StartRemotePut.class has changed
Binary file out/production/classes/christie/test/RemoteTake/CreateRemoteTakeTest.class has changed
Binary file out/production/classes/christie/test/RemoteTake/RemoteTakeTest.class has changed
Binary file out/production/classes/christie/test/RemoteTake/StartRemoteTake.class has changed
Binary file out/production/classes/christie/test/TestLocal/StartTest.class has changed
Binary file out/production/classes/christie/test/TestLocal/TestCodeGear.class has changed
Binary file out/production/classes/christie/test/ring/CheckMyName.class has changed
Binary file out/production/classes/christie/test/ring/ConnectManager.class has changed
Binary file out/production/classes/christie/test/ring/CreateFlipCodeGear.class has changed
Binary file out/production/classes/christie/test/ring/FlipCodeGear.class has changed
Binary file out/production/classes/christie/test/ring/StartCount.class has changed
Binary file out/production/classes/christie/test/ring/StartRingTest.class has changed
Binary file out/production/classes/christie/test/topology/localTestTopology/LTRemoteIncrement.class has changed
Binary file out/production/classes/christie/test/topology/localTestTopology/StartLocalTestTopology.class has changed
Binary file out/production/classes/christie/test/topology/localTestTopology/StartTorqueTestTopology.class has changed
Binary file out/production/classes/christie/test/topology/treeTestTopology/ChildCodeGear.class has changed
Binary file out/production/classes/christie/test/topology/treeTestTopology/ParentCodeGear.class has changed
Binary file out/production/classes/christie/test/topology/treeTestTopology/StartTreeTestTopology.class has changed
Binary file out/production/classes/christie/topology/HostMessage.class has changed
Binary file out/production/classes/christie/topology/manager/CheckComingHost.class has changed
Binary file out/production/classes/christie/topology/manager/ConfigWaiter.class has changed
Binary file out/production/classes/christie/topology/manager/CreateHash.class has changed
Binary file out/production/classes/christie/topology/manager/CreateTreeTopology.class has changed
Binary file out/production/classes/christie/topology/manager/FileParser.class has changed
Binary file out/production/classes/christie/topology/manager/IncomingHosts.class has changed
Binary file out/production/classes/christie/topology/manager/Parent.class has changed
Binary file out/production/classes/christie/topology/manager/ParentManager.class has changed
Binary file out/production/classes/christie/topology/manager/RecordTopology.class has changed
Binary file out/production/classes/christie/topology/manager/SearchHostName.class has changed
Binary file out/production/classes/christie/topology/manager/StartTopologyManager.class has changed
Binary file out/production/classes/christie/topology/manager/TopologyFinish.class has changed
Binary file out/production/classes/christie/topology/manager/TopologyManager.class has changed
Binary file out/production/classes/christie/topology/manager/TopologyManagerConfig.class has changed
Binary file out/production/classes/christie/topology/manager/TopologyType.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/CreateTask.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/KeepAlive.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/ListManager.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/RemoveTask.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/RespondData.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/RespondPing.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/StartKeepAlive.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/TaskExecuter.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/TaskInfo.class has changed
Binary file out/production/classes/christie/topology/manager/keepalive/TaskType.class has changed
Binary file out/production/classes/christie/topology/node/ConfigurationFinish.class has changed
Binary file out/production/classes/christie/topology/node/CreateConnectionList.class has changed
Binary file out/production/classes/christie/topology/node/IncomingConnectionInfo.class has changed
Binary file out/production/classes/christie/topology/node/PrepareToClose.class has changed
Binary file out/production/classes/christie/topology/node/Start.class has changed
Binary file out/production/classes/christie/topology/node/StartTopologyNode.class has changed
Binary file out/production/classes/christie/topology/node/TopologyNode.class has changed
Binary file out/production/classes/christie/topology/node/TopologyNodeConfig.class has changed
Binary file out/test/classes/META-INF/cr.ie.u_ryukyu.ac.jp.Christie.main.kotlin_module has changed
Binary file out/test/classes/christie/blockchain/HashUtilTest.class has changed
Binary file out/test/classes/christie/example/FizzBuzz/Counter.class has changed
Binary file out/test/classes/christie/example/FizzBuzz/FizzBuzz.class has changed
Binary file out/test/classes/christie/example/FizzBuzz/StartFizzBuzz.class has changed
Binary file out/test/classes/christie/example/HelloWorld/HelloWorldCodeGear.class has changed
Binary file out/test/classes/christie/example/HelloWorld/StartHelloWorld.class has changed
Binary file out/test/classes/christie/example/OddEven/EvenCodeGear.class has changed
Binary file out/test/classes/christie/example/OddEven/OddCodeGear.class has changed
Binary file out/test/classes/christie/example/OddEven/StartOddEven.class has changed
Binary file out/test/classes/christie/localTestTopology/localTestTopology.class has changed
Binary file src/.DS_Store has changed
Binary file src/main/.DS_Store has changed
Binary file src/main/java/.DS_Store has changed
Binary file src/main/java/christie/.DS_Store has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/christie/daemon/Connection.java.orig	Tue Jan 08 19:03:33 2019 +0900
@@ -0,0 +1,74 @@
+package christie.daemon;
+
+import java.awt.*;
+import java.net.Socket;
+import java.nio.ByteBuffer;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import christie.datagear.command.Command;
+
+public class Connection {
+
+    public Socket socket;
+    public String name;
+    public LinkedBlockingQueue<Command> sendQueue = new LinkedBlockingQueue<Command>();
+    public boolean sendManager = true;
+
+    public Connection(Socket socket) {
+        this.socket = socket;
+    }
+
+    public Connection() {}
+
+    public void sendCommand(Command cmd) {
+        try {
+            sendQueue.put(cmd);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getInfoString() {
+        return socket.getInetAddress().getHostName()
+                + ":" + socket.getPort();
+    }
+
+
+    public void close(){
+        try {
+            socket.shutdownOutput();
+            socket.shutdownInput();
+            socket.close();
+        } catch (Exception e) { }
+        //putConnectionInfo();
+
+    }
+
+    /*
+    public void putConnectionInfo() {
+        if (name!=null) {
+            ConnectionInfo c = new ConnectionInfo(name, socket);
+            ReceiveData rData = new ReceiveData(c);
+            DataSegment.getLocal().put("_DISCONNECT", rData, false);
+            if (sendManager) {
+                DataSegment.get("manager").put("_DISCONNECTNODE", rData, false);
+                sendManager = false;
+            }
+        }
+
+    }*/
+    public synchronized void write(Command cmd) {
+        ByteBuffer buffer = cmd.convert();
+
+        try {
+            while (buffer.hasRemaining()) {
+                socket.getChannel().write(buffer);
+            }
+            //System.out.println("write : " + cmd.key);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/christie/topology/manager/SearchHostName.java.orig	Tue Jan 08 19:03:33 2019 +0900
@@ -0,0 +1,94 @@
+package christie.topology.manager;
+
+
+import christie.annotation.Peek;
+import christie.annotation.Take;
+import christie.codegear.CodeGear;
+import christie.codegear.CodeGearManager;
+import christie.topology.HostMessage;
+//import org.msgpack.type.ValueFactory;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+
+public class SearchHostName extends CodeGear {
+
+    @Take // reconnect NodeInfo
+    HostMessage reconnectHost;
+
+    @Peek
+    HashMap<String, LinkedList<HostMessage>> topology;
+
+    @Peek
+    boolean running;
+
+
+    public SearchHostName(){
+
+    }
+
+    @Override
+    protected void run(CodeGearManager cgm) {
+
+
+        // Question: remove処理 どうしようか. いらない気もする.
+        // DataSegment.remove(hostInfo.absName);
+
+        String nodeName = reconnectHost.getNodeName();
+        String hostName = reconnectHost.getHostName();
+        int port = reconnectHost.getPort();
+
+        cgm.createRemoteDGM(nodeName, hostName, port);
+        getDGM(nodeName).put("nodeName", nodeName);
+
+        // put Host dataSegment on reconnect node
+        if (topology.containsKey(nodeName)) {
+
+            // Question: これはバグ...?
+            // ods.put(reconnectHost.absName, "dummy"); // this is bug
+
+            if (running){
+                getLocalDGM().put(nodeName, "");
+            }
+
+
+
+            LinkedList<HostMessage> hostList = topology.get(nodeName);
+            for (HostMessage host : hostList){
+                getLocalDGM().put(nodeName, host);
+                System.out.println("put data in "+ nodeName);
+            }
+        }
+
+        // update topology information
+        for (LinkedList<HostMessage> list :topology.values()){
+            for (HostMessage host : list){
+
+                // find and update old info
+                if (!nodeName.equals(host.getNodeName())) continue;
+
+                if (!hostName.equals(host.getHostName()) || port != host.getPort()){
+                    host.setHostAndPort(hostName, port);
+
+                    getLocalDGM().put(host.getNodeName(), host);
+
+                } else {
+                    // nothing to do ?
+                }
+            }
+        }
+
+        for (LinkedList<HostMessage> list :topology.values()){
+            System.out.print(list.get(0).getRemoteNodeName()+" : ");
+            for (HostMessage host : list){
+                System.out.print("[ "+host.getNodeName()      +" "
+                                     +host.getHostName()      +" "
+                                     +host.getPort()          +" "
+                                     +host.getConnectionName()+" "
+                                     +host.getRemoteNodeName()+" ]");
+            }
+            System.out.println();
+        }
+    }
+
+}
Binary file src/test/.DS_Store has changed
Binary file src/test/java/.DS_Store has changed
Binary file src/test/java/christie/.DS_Store has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/FizzBuzz/Counter.java	Tue Jan 08 19:03:33 2019 +0900
@@ -0,0 +1,23 @@
+package christie.example.FizzBuzz;
+
+import christie.annotation.Peek;
+import christie.annotation.Take;
+import christie.codegear.CodeGear;
+import christie.codegear.CodeGearManager;
+
+public class Counter extends CodeGear {
+    @Take
+    int num;
+
+
+    @Override
+    protected void run(CodeGearManager cgm) {
+        //System.out.println(num);
+        if (num <= 100) {
+            getDGM("fizzBuzz").put("num", num);
+            cgm.getLocalDGM().put("num", num + 1);
+            cgm.setup(new Counter());
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/FizzBuzz/FizzBuzz.java	Tue Jan 08 19:03:33 2019 +0900
@@ -0,0 +1,28 @@
+package christie.example.FizzBuzz;
+
+import christie.annotation.Peek;
+import christie.annotation.Take;
+import christie.codegear.CodeGear;
+import christie.codegear.CodeGearManager;
+
+public class FizzBuzz extends CodeGear {
+
+    @Take
+    int num;
+
+
+
+    @Override
+    protected void run(CodeGearManager cgm) {
+        if (num % 3 == 0 && num  % 5 == 0) {
+            System.out.println(num + ":FizzBuzz");
+        }else if(num % 3 == 0){
+            System.out.println(num + ":Fizz");
+        }else if(num % 5 == 0){
+            System.out.println(num + ":Buzz");
+        }else{
+            System.out.println(num);
+        }
+        cgm.setup(new FizzBuzz());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/FizzBuzz/StartFizzBuzz.java	Tue Jan 08 19:03:33 2019 +0900
@@ -0,0 +1,24 @@
+package christie.example.FizzBuzz;
+
+import christie.annotation.Peek;
+import christie.annotation.Take;
+import christie.codegear.CodeGearManager;
+import christie.codegear.StartCodeGear;
+
+public class StartFizzBuzz extends StartCodeGear {
+    @Take
+    int i = 1;
+
+    public StartFizzBuzz(CodeGearManager cgm) {
+        super(cgm);
+    }
+
+    public static void main(String[] args) {
+        CodeGearManager counter = createCGM(10001);
+        CodeGearManager fizzBuzz = createCGM(10002);
+        counter.setup(new Counter());
+        fizzBuzz.setup(new FizzBuzz());
+        counter.createRemoteDGM("fizzBuzz","localhost",10002);
+        counter.getLocalDGM().put("num", 1);
+    }
+}
--- a/src/test/java/christie/example/OddEven/EvenCodeGear.java	Tue Jan 08 19:00:34 2019 +0900
+++ b/src/test/java/christie/example/OddEven/EvenCodeGear.java	Tue Jan 08 19:03:33 2019 +0900
@@ -14,9 +14,11 @@
 
     @Override
     protected void run(CodeGearManager cgm) {
-        if (finishCount == even) return;
         System.out.println(even + " : even");
-        getDGM("odd").put("odd", even + 1);
-        cgm.setup(new EvenCodeGear());
+        if (finishCount != even) {
+            getDGM("odd").put("odd", even + 1);
+            cgm.setup(new EvenCodeGear());
+        }
     }
-}
+
+}
\ No newline at end of file
--- a/src/test/java/christie/example/OddEven/OddCodeGear.java	Tue Jan 08 19:00:34 2019 +0900
+++ b/src/test/java/christie/example/OddEven/OddCodeGear.java	Tue Jan 08 19:03:33 2019 +0900
@@ -14,9 +14,10 @@
 
     @Override
     protected void run(CodeGearManager cgm) {
-        if (finishCount - 1 == odd) return;
         System.out.println(odd + " : odd");
+        if (finishCount + 1 != odd) {
         getDGM("even").put("even", odd + 1);
         cgm.setup(new OddCodeGear());
+        }
     }
 }