Simple Sink

SimpleSink.java is a class allows easy creation of sinks.

The Methods

  • Constructor that makes it easy to quickly create a sink specifying a target server
  • monitor_____() methods for defining what channels this sink should monitor
  • subscribe___() methods for requesting a continious stream of data points that can then be accessed via fetch()
  • request() methods reqest single slices of data
  • Helper methods such as methods for determing the available channels on a server

Single Request

The sink issues a request for a specific piece of data from a single channel.

1
2
3
4
5
6
7
8
9
10
11
12
public static void example() throws SAPIException{
    SimpleSink sink = new SimpleSink("Sink");
    
    double time = 1111111111;
    sink = new SimpleSink("Sample", "184.169.139.37", 3333);
    sink.monitorChannel("test/tmp");
    ChannelMap map = sink.request(time);
    System.out.println(map.GetDataAsFloat32(0)[0]);
    sink.close();
}

Subscribe to All

The sink subscribes to all the data in the server starting at the oldest point.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public static void example() throws SAPIException{
    SimpleSink sink = new SimpleSink("Sink");
    
    sink = new SimpleSink("Sample", "184.169.139.37", 3333);
    sink.monitorAll();
    
    sink.subscribeToOldest();
    
    //Fetch 50 slices  of data
    for(int r=0; r <50; r++){
        
        //fetch data
        ChannelMap map = sink.fetch();
        
        //Print it
        for(int i=0; i < map.NumberOfChannels(); i++){
            
            System.out.println(
                map.GetName(i) + "\t"
                +map.GetTimes(i)[0] + "\t"
                +map.GetDataAsFloat32(i)[0] + "\t"
            );
        }
    }
    sink.close();
}
Open Source DataTurbine Initiative © 2016 Frontier Theme