Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ajay.Gov
    @ajay-gov
    Actually it is possible to start the Swim server via a Java class wrapper..in fact the BasicPlane (https://github.com/swimos/cookbook/blob/master/planes/src/main/java/swim/basic/BasicPlane.java#L66-L70) does exactly that. However the details are in the line (final Kernel kernel = ServerLoader.loadServer();) We will add some documentation deconstructing that line. If you'd like to dive into the details of how it is loaded it's here: https://github.com/swimos/swim/blob/master/swim-system-java/swim-mesh-java/swim.server/src/main/java/swim/server/ServerLoader.java#L44-L60
    Regarding springboot, we haven't tried it yet. We might do this at some point
    Kara Rawson
    @1-14x0r
    great, you read my mind, that was my next question.. ill dig around in those
    Ajay.Gov
    @ajay-gov

    @1-14x0r So we have a Custom ServerLoader to override ports. Here is the link to it: https://gist.github.com/ajay-gov/408ab8fbc252419f8a481f2231ecf677. The line that changes the port is here : https://gist.github.com/ajay-gov/408ab8fbc252419f8a481f2231ecf677#file-myserverloader-L109-L113. This assumes that the property name passed into the java class is 'port'

    So give this new ServerLoader you have to do the following:

    1. Change the Plane code to use the new server loader in your Plane class. So change the line here (https://github.com/swimos/cookbook/blob/master/planes/src/main/java/swim/basic/BasicPlane.java#L66) to be:
      final Kernel kernel = MyServerLoader.loadServer();
    2. If you are running from gradle then you need to pass the System property to the gradle run task. Unfortunately gradle doesn't do this by default. So add the following line to the gradle run task: (using this as an example gradle file: https://github.com/swimos/cookbook/blob/master/planes/build.gradle#L59)
      systemProperties System.getProperties(). So the run task would look like this:
    run {
        dependsOn jar
        systemProperties System.getProperties()
        doFirst {
          jvmArgs += [
            '--module-path', files(configurations.runtimeClasspath, jar.archivePath).asPath,
            '--module', "${moduleName}/${mainClassName}"
          ]
          classpath = files()
        }
      }
    To run it you would do: ./gradlew run -Dport=$PORT. I hope Heroku lets u access the port from the commandline.
    Kara Rawson
    @1-14x0r
    ty for the info, yes this in the only place, im testing all possible vectors now, but im pretty sure its the only place
    Ajay.Gov
    @ajay-gov
    looks like heroku is using uppercase for the port system property, so please change the code here (https://gist.github.com/ajay-gov/408ab8fbc252419f8a481f2231ecf677#file-myserverloader-L110) to use "PORT" instead of "port"
    Kara Rawson
    @1-14x0r
    you have to use Procfile to define custom CLI
    Kara Rawson
    @1-14x0r
    the problem is with how heroky handles gradle
    it always autodetects the buildpack, and autogenerates a command, regardless if you soecify a procfil
    Ajay.Gov
    @ajay-gov
    @1-14x0r can u share with us the command it generates?
    Ajay.Gov
    @ajay-gov
    @1-14x0r It seems that heroku runs the task: 'gradle stage' command if it doesn't recognize the framework you are using which is what it's doing for swim apps I think. Can you confirm?
    it seems that you can override this by setting a config variable GRADLE_TASK. So can you try setting this in the config var to the following and give it a try:
    heroku config:set GRADLE_TASK="run -Dport=$PORT"
    We are basing this on what we read here: https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku#the-procfile
    Kara Rawson
    @1-14x0r
    thank you i will test that out today
    tlecouffe
    @tlecouffe
    Hi.. Is there documentation available describing how to deploy to azure iot edge? Back in July there was an indication that it was coming.. Just curious if that's out there yet? Thanks!
    Scott Clarke
    @scottswim
    @tlecouffe Hi Tyler, we're currently in the process of updating our Azure IoT offering in the Marketplace with a new example app and lots of documentation around it however we are still working through the azure approval process. That said, i would love you pass you over a link and hopefully get a bit of feedback from you on it. Can you pass along your email either here or emails us at developers@swim.ai and i will pass along the link to you? I think you will find the updates and new documentation to be much more helpful and i look forward to hearing what you think. As always, we are here to answer any questions you have.
    tlecouffe
    @tlecouffe
    That
    Scott Clarke
    @scottswim
    great! i have passed along an email with a link. Let us know if you have any questions!
    cvsekhar
    @cvsekhar
    I have a general question, I know we can have a lot of swim agents, but designing one agent per docker image and deploying those is a bad architecture or it is not a terrible idea ?
    Brad Johnson
    @johnson_brad_twitter
    @cvsekhar I'm not the best person to answer, so @scottswim @ajay-gov or anyone else please chime in. It's certainly possible to run only one Web Agent per Docker image (and it would work just fine). I'd only recommend that as an architecture decision if it was to keep uniform deployment across a larger application, or in other words, for the sake of simplicity. Otherwise that's probably a bit more infrastructure than is necessary.
    @cvsekhar Here's an example greenhouse app that @scottswim built which uses Docker, which may be a helpful reference: https://github.com/swimos/greenhouse
    cvsekhar
    @cvsekhar
    @johnson_brad_twitter Yes its a purely architectural decision, when we introduce smartness into those agents like the traditional Agents as discussed in peter norvig book and we have so many agents acting on behalf of real things what is the thin line of deploying these apps is where I am getting lost.
    Ajay.Gov
    @ajay-gov
    @cvsekhar In general, having more web agents is the right pattern. Web agents guarantee single threaded access and having just one web agent means that all requests will go through that web agent which ends up as a bottle neck. On the contrary having multiple web agents means that different threads can process the requests to the different web agents in parallel which scales really well. Also having one or more web agents is a design decision which should be made independent of how you package the swim application (i.e. docker image or deb package etc.)
    cvsekhar
    @cvsekhar
    @ajay-gov , oops when I meant one WebAgent , is when it is curtailed to specific functionality say like a smart thermostat web agent
    Ajay.Gov
    @ajay-gov
    @cvsekhar For that use case it makes perfect sense to have one Web Agent for a thermostat.
    cvsekhar
    @cvsekhar
    we can have these deployed as individual docker images for each thermostat or we can have them in one docker image representing all the thermostats. but when we introduce the smartness into these agents like depending on the values it receives and we need to take action based on some intelligent decision is where I am getting lost wether to represent each thermostat as a docker image or single a docker image handling all those thermostat represented by a webagent and driven by an id
    Ajay.Gov
    @ajay-gov
    right, if your use cased involves web agents communicating with each other to make intelligent decisions then if having one thermostat web agent per docker image will involve multiple messages being sent across the different docker images (network cost)
    you can use one docker image and set up multiple thermostat web agents and not incur the network cost. There is no extra work in writing code. Each Thermostat Web Agent will have a different id and will get instantiated dynamically as a message is sent to that URI (eg: /thermostat/1 or /thermostat/2)
    Having one docker image with all the thermostat web agents also reduces the overhead of managing multiple images since you just have one
    cvsekhar
    @cvsekhar
    @ajay-gov Okie gotcha
    Codeseys
    @Codeseys
    Hi,
    I was just wondering if the plane that the unit agents are on are subject to commands in
    Commands that come from a command lane *
    Brad Johnson
    @johnson_brad_twitter
    Hi @Codeseys . Thanks for posting. Tagging swimOS pros @ajay-gov and @freyadyu who can help you out. Stay tuned!
    Ajay.Gov
    @ajay-gov
    @Codeseys You can think of the plane as the container that holds Web Agents. You can send commands to a command lane in a Web Agent which gets routed through the plane. So a plane is analogous to a http server in that respect. In the REST world, you would make POST requests to a particular end-point which gets routed via the http server.
    blackduck-joe
    @blackduck-joe
    I have a parallel processing problem that I think might be ideal for Swim, but could use some pointers/advice. Each individual unit of work requires processing multiple (1-20) input packets that arrive over time, but are easily correlated by a unique Id. Processing consists of three distinct stages: A, B, and C – my thinking thus far would be that these would be three WebAgents. The “A” stage fills in “Lanes” as the complete set of input packets arrive. Sorry, but it gets more complex here. Stage “B” always occurs, but depending on the type of input data it may need to wait for all the input packets to Stage A to complete, or it can start processing right away. I think a Swim Plane allows for this, but confirmation would be appreciated. Finally, Stage “C” logically extends Stage “B” but only happens under certain data conditions. Thus, Stage “C” adds additional ‘lanes’ for certain types of data. Can this be accommodated? The final results need to be “egressed” to another system. I believe this is a decent fit for the Swim architecture; however my real questions concern scale: the process described is per installation. If this is installed in several hundred locations, then there will be WIDE variance in throughput/bandwidth required. Location 1, might require minimal usage/throughput as it is not heavily used. Location 2 may be just the opposite and require multiple instances of the various WebAgents to keep up with incoming processing. Are there descriptions/pointers/examples as to how Swim scales this way?
    Scott Clarke
    @scottswim
    First off, yes this is a perfect situation to use Swim. For Stage A, i would create a webagent per unique ID. Stage B would be a single webagent which collects the incoming data to a lane and each time data arrives it would decide what to do based on the data it has as well as what arrived. That logic would happen on the the didSet or didUpdate, depending on what kind of lane you are using. From there, the lane in Stage B can populate Stage C and likeway Stage C would have logic in its didSet/didUpdate which decides what it need to do each time the lane gets data. The Swim Plane itself is mostly used to define the routing to all the various webagents which make up the application. We also use the swim plane to kick off any other tasks or processes which need to happen sich as importing CSV data or triggering a webagent to startup. I think our greenhouse demo may be a good example for you to start with as its a single app which is distrubuted across multiple devices and has lanes which talk to other lanes based on sensor data coming into the webagents. You can find the full source and documentation for that example here: https://github.com/swimos/greenhouse
    Please feel free to reach out to us when/if you have questions or problems. We are happy to help out.
    We also have lots of documentation on swim itself. That can be found at https://developer.swim.ai/, https://docs.swimos.org/java/latest/index.html, https://docs.swimos.org/js/latest/index.html and inside the tutorials on github at https://github.com/swimos
    blackduck-joe
    @blackduck-joe
    @scottswim - thank you - found all the tutorials, but if I saw the greenhouse example I missed it! Before I go very far at all I want/need to understand how an "app" distributes and scales across multiple devices so that should be perfect!
    Ajay.Gov
    @ajay-gov
    @blackduck-joe In general Swim scales better when the processing is distributed across multiple Web Agents. Web Agents are created for every unique URI i.e when you access /stageA/1, /stageA/2 etc. In your specific case, you will have a Swim Plane per device each of which is running the same application. Each installation can be configured with appropriate memory based on the load requirements.
    For example: In Location1 which has minimal usage/throughput you can give the Application low memory (and create few Web agents). In Location 2 which has a high load, give the Application a lot of memory (and create a lot of Web Agents). You can alter the memory settings when you deploy the application. For instance:
    java -Xmx 128M... for Location1 and java -Xmx 2G... for Location 2
    Ajay.Gov
    @ajay-gov
    @blackduck-joe One other thing, Web Agents execute in parallel. So if you know that an environment is going to have a high load then use a multi-core processor if possible.
    Codeseys
    @Codeseys
    @ajay-gov I was wondering if there is a default "start on run" function/command for the web agents
    also is there is a possibility for using the swim framework as a data streaming structure for a stock simulator? or a 3d open-world online game?
    Ajay.Gov
    @ajay-gov
    @Codeseys Maybe you know this but I just want to make sure -The Web Agent class that you write is just a definition of the code associated with it. Web Agents are instantiated when you invoke the uri associated with it. So if you have a URI pattern /myagent/:id for a type MyAgent, invoking /myagent/1 will create a new instance of the MyAgent type. So when you say "start on run", I am assuming that you want to start a particular instance of the web agent. You can do so by sending a command to that Web Agent. Here is an example: https://github.com/swimos/cookbook/blob/master/web_agents/src/main/java/swim/basic/BasicPlane.java#L38
    So you could do this when you start the Plane in the main method. Currently this is the only way to do it. In our next release you will be able to instantiate new Web Agents with know URIs by adding it in the recon file where you define the plane
    Ajay.Gov
    @ajay-gov
    Regarding your question about a stock simulator or a 3d open-world online game- these are really good use cases for swim. You just model web agents appropriately for these applications. For the stock simulator, each Stock could be a Web Agent and you could add lanes in Stock Web Agent to store bids from investors. Based on the bid received the stock price (which will be a lane) can fluctuate. Each investor could be a Web Agent as well where you can track their bids , order history and holdings.
    Codeseys
    @Codeseys
    oooook
    thanks
    ill look into it