Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mihini-dev] RE : Mihini PushData Policy

Hi,

I think I understand your problem.
Data Policies manages the way data are sent to the M3DA server once buffered in the agent.
Data Policy is meant to decouple the frequency used to push the data to the agent and the frequency used to send it to the server.

The data policy will not generate any data automatically, thus you still have to create a periodic task if you need to generate the data periodically.
Another way to put it: if you call only once a push API with your house.door variable, the server will receive it only once, whatever the policy used.

You can try something like that:

local timer = require"timer"
local asset

local function periodicpush()
    asset:pushdata ('door', "open", 'everyminute')
end

-- init steps:
local asset = airvantage.newasset("house")
assert(asset:start())

--start periodic task
timer.periodic(60, periodicpush)


Please note that in that case you might want to determine if 'everyminute' is the correct policy for your use case: the previous code results in pushing a new data point each minute, then 'everyminute' policy will buffer this data 1 more minute before triggering the flush to the server.


Regards,
________________________________________
De : mihini-dev-bounces@xxxxxxxxxxx [mihini-dev-bounces@xxxxxxxxxxx] de la part de satishbaganal iit [satishbaganal@xxxxxxxxx]
Date d'envoi : jeudi 20 novembre 2014 15:04
À : mihini-dev@xxxxxxxxxxx
Objet : [mihini-dev] Mihini PushData Policy

Hi Guys

     I have configured the data.policy as per below.

agent.config.data.policy.everyminute={period=60}  --consolidation policy every minute
agent.config.data.policy.every10minutes={period=10*60}  --sending data policy every 10 minutes

    And i am creating asset as per the following code and i am
trying to push the data on every minute interval but i am getting
the data in m3da server only one time at start of code running.

assert(airvantage.init())
local asset = airvantage.newasset("house")
assert(asset:start())
asset:pushdata ('door', "open", 'everyminute')

    My guess is i should get the data on every minute please guide me
how to push data on every minute bases and what is the meaning of
Nov 20 19:18:01  Mihini: 2014-11-20 19:18:01 DATAMGR-INFO: flushing policy "everyminute".

Here is my syslog output:

Nov 20 19:16:58  Mihini: 2014-11-20 19:16:58 EMP-DEBUG: [->RCV] [CMD] #1 Register "house"
Nov 20 19:16:58  Mihini: 2014-11-20 19:16:58 EMP-DEBUG: payload = house, type = string, serialized = "house"
Nov 20 19:16:58  Mihini: 2014-11-20 19:16:58 ASSCON-DETAIL: Registering [table: 0x8cfc8d0] as asset (house)...
Nov 20 19:16:58  Mihini: 2014-11-20 19:16:58 ASSCON-INFO: Asset registered, name="house", id=table: 0x8cfc8d0.
Nov 20 19:16:58  Mihini: 2014-11-20 19:16:58 EMP-DEBUG: [<-SND] [RSP] #0 Register null
Nov 20 19:16:59  Mihini: 2014-11-20 19:16:59 EMP-DEBUG: [->RCV] [CMD] #1 PData {"data":"open","policy":"everyminute","asset":"house","path":"door"}
Nov 20 19:16:59  Mihini: 2014-11-20 19:16:59 EMP-DEBUG: payload = table: 0x8cf6620, type = table, serialized = {"data":"open","policy":"everyminute","asset":"house","path":"door"}
Nov 20 19:16:59  Mihini: 2014-11-20 19:16:59 EMP-DEBUG: [<-SND] [RSP] #0 PData null
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 DATAMGR-DETAIL: Policy "everyminute" setup to triggered after latency
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 M3DA-SESSION-INFO: Opening default session #6
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 DATAMGR-DETAIL: sending table house:door (1 rows of 1 columns) to server
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 M3DA-TRANSPORT-DEBUG: Opening socket
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 BYSANT-M3DA-DEBUG: Streaming 8 bytes of payload
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 BYSANT-M3DA-DEBUG: Streaming header
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 BYSANT-M3DA-DEBUG: Streaming 13 bytes of payload
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 BYSANT-M3DA-DEBUG: Streaming footer nil
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 M3DA-SESSION-DEBUG: Waiting for server response...
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 M3DA-TRANSPORT-DEBUG: Received 13 bytes from server
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 M3DA-SESSION-INFO: Closing default session #6 with status 200.
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 M3DA-SESSION-DEBUG: Received a 0 bytes message
Nov 20 19:17:01  Mihini: 2014-11-20 19:17:01 SCHED-PIPE-DEBUG: Pipe table: 0x8cbae38 empty, :receive() waits for data
Nov 20 19:17:31  Mihini: 2014-11-20 19:17:31 M3DA-TRANSPORT-DEBUG: Closing socket: closed
Nov 20 19:18:01  Mihini: 2014-11-20 19:18:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:19:01  Mihini: 2014-11-20 19:19:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:20:01  Mihini: 2014-11-20 19:20:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:21:01  Mihini: 2014-11-20 19:21:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:22:01  Mihini: 2014-11-20 19:22:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:23:01  Mihini: 2014-11-20 19:23:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:24:01  Mihini: 2014-11-20 19:24:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:25:01  Mihini: 2014-11-20 19:25:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:25:30  Mihini: 2014-11-20 19:25:30 DATAMGR-INFO: flushing policy "every10minutes"
Nov 20 19:26:01  Mihini: 2014-11-20 19:26:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:27:01  Mihini: 2014-11-20 19:27:01 DATAMGR-INFO: flushing policy "everyminute"
Nov 20 19:28:01  Mihini: 2014-11-20 19:28:01 DATAMGR-INFO: flushing policy "everyminute"


My m3da server output:

{"house.door":[{"value":["open"],"timestamp":"1416491221101"}]}



Back to the top