Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[simulator][machine] Simulator config, command and improve logic #13

Merged
merged 18 commits into from
Nov 23, 2016

Commits on Nov 17, 2016

  1. [cmd] Add simulator

    - alias sim
    - No real logic is added
    at15 committed Nov 17, 2016
    Configuration menu
    Copy the full SHA
    dbcbc71 View commit details
    Browse the repository at this point in the history

Commits on Nov 19, 2016

  1. [util] Init cmd flag and log

    - use cobra to bind command line flag
    - use logrus for logging
    at15 committed Nov 19, 2016
    Configuration menu
    Copy the full SHA
    7ecdba3 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2016

  1. [util] read config using viper

    which introduced a lot of packages
    at15 committed Nov 20, 2016
    Configuration menu
    Copy the full SHA
    e3e9261 View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2016

  1. [simulator][machine][config] Init reading config

    - Add machine simulator config struct, which supports: num, start, end, step
    - add util function for read config file in test (TODO: don't know if it will have sideffect if is called multiple times)
    at15 committed Nov 21, 2016
    Configuration menu
    Copy the full SHA
    24e067d View commit details
    Browse the repository at this point in the history
  2. [simulator][machine] Move to sub package

    - the machine.go is already 150+ lines with current dumbest simulation logic,
    so should put it in sub package and split to several files
    - Add format script in Ayi, which will call gofmt
    at15 committed Nov 21, 2016
    Configuration menu
    Copy the full SHA
    e3d5dcd View commit details
    Browse the repository at this point in the history
  3. [simulator][machine] Split into several files

    - machine is the pojo and factory for machine
    - simulator is the real machine simulator
    at15 committed Nov 21, 2016
    Configuration menu
    Copy the full SHA
    50f257b View commit details
    Browse the repository at this point in the history
  4. [generator][time][value] Initial package

    - intial time and value sub package under generator
    - add fixed interval
    - add constant
    - TestNewGenerator shows it is working
    at15 committed Nov 21, 2016
    Configuration menu
    Copy the full SHA
    c97fac0 View commit details
    Browse the repository at this point in the history
  5. [simulator][machine] Use machine as gen unit

    - add functions ending with New, in order to have old code as example, will remove old and change name after migration
    - add value generator interface
    - when generate default machine, add seriesWithValueGenerater into machine
    - machine has different array for keep int and double series
    at15 committed Nov 21, 2016
    Configuration menu
    Copy the full SHA
    1449a1b View commit details
    Browse the repository at this point in the history
  6. [simulaor][machine] The new simulator is working

    - see TestMachineSimulatorNew
    - TODO: why I saw more cpu_core=3 in log ouput
    - TODO: remove old generator code
    at15 committed Nov 21, 2016
    Configuration menu
    Copy the full SHA
    1e205af View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2016

  1. [simulator][machine] Remove old simulator code

    - generate machine
    - add default machine
    - start
    - related property and methods in simulator interface
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    4b21484 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0e09db9 View commit details
    Browse the repository at this point in the history
  3. [simulator][machine] delete old point generator

    - delete interface for point generator
    - delete constant int point generator
    - delete series with point generator
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    a908a4a View commit details
    Browse the repository at this point in the history
  4. [cmd][simulator][machine] Init cmd content

    - the simulator config struct is actually never used
    - TODO: not output in current default setting, might be problem with config file
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    417ee97 View commit details
    Browse the repository at this point in the history
  5. [bug][simulator][machine] panic for null ptr

    It seems the serializer is not properly initialized
    ````
    DEBU[0000] enable debug logging                          pkg=x.util
    DEBU[0000] config file xephon-b.yml is loaded            pkg=x.cmd
    DEBU[0000] triggered simulator command                   pkg=x.cmd
    DEBU[0000] machine simulator start                       pkg=x.s.machine
    DEBU[0000] need to serialize                             pkg=x.s.machine
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x498eed]
    
    goroutine 21 [running]:
    panic(0x7bc3e0, 0xc420016120)
    	/home/at15/app/go/src/runtime/panic.go:500 +0x1a1
    github.com/xephonhq/xephon-b/pkg/simulator/machine.(*MachineSimulator).Start.func2(0xc42007cde0, 0xc4200aa630, 0xc42007ce40, 0xc42017c290)
    	/home/at15/workspace/src/github.com/xephonhq/xephon-b/pkg/simulator/machine/simulator.go:84 +0x11d
    created by github.com/xephonhq/xephon-b/pkg/simulator/machine.(*MachineSimulator).Start
    	/home/at15/workspace/src/github.com/xephonhq/xephon-b/pkg/simulator/machine/simulator.go:92 +0x20e
    ````
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    17a01e9 View commit details
    Browse the repository at this point in the history
  6. [simualtor][machine] fix reading arguments

    - treated output as encoding and cased the null pointer problem
    - change example num to 3 for less output when try the command
    - run `xb sim --debug --type json` to see json output
    - TODO: json serialize should have `\n` in order to be read by others
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    b58466f View commit details
    Browse the repository at this point in the history
  7. [simulator][machine] support file ouput

    - ignore *.dat file as its the default output file suffix
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    fe62f59 View commit details
    Browse the repository at this point in the history
  8. [serialize][json] Add \n

    - TODO: use append may not be the most efficient way. But adding a wrapper for writer might be more messy
    since the writer should know little(nothing) about the serializer
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    801bcd0 View commit details
    Browse the repository at this point in the history
  9. [simulator][cmd] close file

    - though it seems file without calling f.Close
    at15 committed Nov 23, 2016
    Configuration menu
    Copy the full SHA
    78d1c30 View commit details
    Browse the repository at this point in the history