ppegusii / cs677-smart-homes-iot Goto Github PK
View Code? Open in Web Editor NEWProgramming Assignment 1: Internet of Things and Smart Homes
License: GNU General Public License v2.0
Programming Assignment 1: Internet of Things and Smart Homes
License: GNU General Public License v2.0
How do we plan to merge our APIs? Your RegisterParams are a bit different from mine in that you are using strings and I am using ints. I wanted to stay away from strings, especially non-constants, to avoid spelling mistakes and reduce data transmitted. Also I thought that we could store all the shared struct definitions in one place to avoid circular imports and repeated code. The gateway seems best because that's the thing that needs to know about them all. What do you think of gateway/api.go
?
Map of node IDs. Replica should filter actions based on map entries.
If possible paxos implementation
a) start gateway on port 6770
b) register temperature sensor it gets device id 0
c) now, start replica 9999
d) register motionsensor it also gets device id 0
Paxos writeup the last part of the assignment
Gateway always returns device ID 0 while registering.
Shouldn't the Smart Outlet state be turned to "On" after Step 2 above.
RPC function that changes the current gateway to communicate with
Register all sensors and devices with gateway
For Leader Election Algorithm using Bully Algorithm with device ID as the decision maker (where Gateway has the highest Device ID) seems apt. It sounds kind of monotony that gateway always wins but that should be the case because:
Reasons:
Update the design document with design decisions, diagrams, etc
Usually it is n * no. of hops to reach the farthest peer. In this case, since each peer is connected to all others. The polling is small right now of 5 secs... will see if there is too much congestion then will increase it.
To fix, be sure that registering devices are a additive action only. When rebalancing, pull registered devices from the database.
Nodes fail during registration because at least one registration request will always error and the code calls log.Fatal on error.
I changed temperature sensor to work, but the other sensors and devices need to be fixed.
changing the struct to:
type RegisterParams struct {
Type Type
Name Name
//Cannot get caller IP from rpc library.
//Might as well send listening port too.
Address string
Port string
// ListenSocket net.TCPAddr
}
Reason: ListenSocket of type net.TCPAddr is difficult to create after finding out the sensor's IP and port where it would listen.
Get id and gateway address and gateway port to send subsequent requests to
Create a screen for manually updating device and sensor states.
Caching implementation
Pending functionality:
Add code for smartoutlet registration. Update the smartoutlet Deviceid field with the valye send by gateway.
Working on it.
Assuming the following to simplify structs in RPCs or limit the number of different RPCs.
Is this OK. I think we can accomplish everything needed with this. Have I overlooked something?
a) both replicas are up and register motion sensor, temperature sensor
b) now, leader replica 9999 goes down
c) try registering door sensor
doorsensor ameetrivedi$ ./doorsensor
2015/05/07 09:18:55 Calling error to 127.0.0.1:6770 for Gateway.Register: Inactive gateway replica: {Address:127.0.0.1 Port:6770}
2015/05/07 09:18:55 Dialing error to 127.0.0.1:9999 for Gateway.Register: dial tcp 127.0.0.1:9999: connection refused
2015/05/07 09:18:55 Could not register with a gateway.
doorsensor ameetrivedi$
If timestamp is added in the regparam of each RPC call, will gateway handle it that way or something else needs to be done for the timestamp?
Now, sendstate() is an RPC call and no more going through
In test: tests/motion_home.json there is a call to sendstate() from Changestate() which results in panic.
2015/05/07 05:55:15 Current state: Motion
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x3e96]
goroutine 9 [running]:
main.(_MotionSensor).sendState(0xc2080c8000)
/Users/ameetrivedi/Desktop/Amee/Projects/CS677/Lab2/src/github.com/ppegusii/cs677-smart-homes-IoT/motionsensor/motionsensor.go:194 +0x196
main.(_MotionSensor).ChangeState(0xc2080c8000, 0xc20801f2c0, 0xc20801f400, 0x0, 0x0)
/Users/ameetrivedi/Desktop/Amee/Projects/CS677/Lab2/src/github.com/ppegusii/cs677-smart-homes-IoT/motionsensor/motionsensor.go:128 +0x20d
reflect.Value.call(0x329960, 0x394d70, 0x13, 0x3c6190, 0x4, 0xc2080a3f28, 0x3, 0x3, 0x0, 0x0, ...)
/usr/local/go/src/reflect/value.go:419 +0x10e5
reflect.Value.Call(0x329960, 0x394d70, 0x13, 0xc2080a3f28, 0x3, 0x3, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:296 +0xbc
Registration from sensor/device done
Add comments everywhere in the current code
Could add a synchronized struct in structs.go, such as SyncString, similar to SyncBool. Using the existing SyncRegGatewayUserParam might be easier.
Why guess the IP? If there are multiple interfaces, an incorrect guess is possible.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.